Minumum size for a texture.

Previous topic - Next topic

jestermon

I put together a 3D clock as my first test project in GLBasic, and encountered an interesting anomaly.
I first made a 2x2 (1st power of 2) texture with only red as a color. This was to be used to texture the "second hand" mesh.
However, I could not see the texture properly on the object until I upped the size to 32x32. Now why would that be?
It's not a problem question, but more one of curiosity, since using a single color texture as small is possible, makes a lot of sense. . .
In DX, a 1x1 texture image is perfect for any single color texture (on any UV-planar mapped model), so I assumed the lowest power of 2 would suffice for OGL.
So what is really the smallest size texture that can be used to texture a mesh in GLBasic? Or is this more a UV issue in OGL?

PS: Can one post small usable projects anywhere on the forum? (I mean more than little code snippits)

Kitty Hello

very strange. It's a driver thing. Usually 4x4 textures work on all devices. I use 8x8 internally to be safe.

you can post code snippets here.
Try this one:

Code (glbasic) Select

LOCAL pix%[]
DIMDATA pix%[], 0xffffffff, 0xffff0000, 0x0000ffff, 0xff0000ff
MEM2SPRITE(pix%[], 0, 2,2)
STRETCHSPRITE 0, 0,0, 100,100
SHOWSCREEN
MOUSEWAIT

jestermon

Yup, it seems to be a driver thing. My clock app can take 2x2 textures on my xoom tablet and htc phone, so Android is very happy with 2x2.
Thanks for your feedback Kitty.... For now I'll stick to the 32x32, which at least works on my DELL XPS, but at least I am aware of it's driver fault. Your sample freaked out on my XPS, and not my Androids - so there's no doubt about it being the driver. (update scheduled :) )

jestermon

#3
Quote from: Ocean on 2012-Sep-05
IIRC, GL-ES 2.0 requires texture bitmaps that have at least 64-bits, or was it 64 pixels ?

No idea. The 2x2 demo then probably works because the bitmap is stretched before rendering. I will investigate this. Thanks Ocean for the heads-up.

Edit: Actual minimum texture size with glGetIntegerv function using GL_MAX_TEXTURE_SIZE enum is 64x64 pixels (spec page 141, table 6.20)
Which means a 64x64 minimum texture size should be best for multi-platform deployment.  This sets a new base for my future projects, and overrides my XPS driver problem ... Good to have some baselines.

Thanks for all the feedback guys, this clears up a lot of confusion for me.

spacefractal

This is very strange and have not seen that before.

I allways use 2x2 or 8x8px (as I use for my game). Howover due this thread its better to been safe and use 64x64px texture (i used 2 of those single color texture in my game). Mightbeen there should been a function (eventuelt inline) to checkout min size and then like that code snippet?
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

matchy

What is the absolute reasoning to use such a small fixed size texture?

Wampus

Quote from: matchy on 2012-Sep-06
What is the absolute reasoning to use such a small fixed size texture?

Have been wondering about that myself.

jestermon

Quote...absolute reasoning to use such a small fixed size texture

Using as small a texture as possible, if you are only using a single color makes a lot of sense if you have something like a cartoon-type car that has many separate meshes, where each piece has it's own color.

Keep in mind that a 512x512 texture takes up 4 times as much memory as a 256x356 texture, and not twice as one would think. A huge texture can often be more resource intensive than a complex model, so it's good practice (professionally at least) to minimize all the resources that you can. For a simple game it's not such a big deal, but for hundreds of objects - size really starts to matter.

GLBasic is low-level enough to reuse resources, since one inserts the same resource in the rendering loop. But in most game engines, these resources are duplicated for each use, since a model may import it's own texture as it is loaded. In DirectX a 1x1 single color texture is an almost standard way of applying a texture, if the mesh itself is not colored. (A .x , .3ds and a few other mesh types have a "color" feature built into the format)

spacefractal

single color texture make seance to do so small texture as possible, that is supported by the system. I do that rather than DRAWRECT, due DRAWRECT might do wrong on some Android systems and hence its cant been used correctly. That is not a bug in glbasic, but limit of the system.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

matchy

jestermon, what the?  :S Generally and specifically, you make no sense. If I least require a 1x1 pixel texture, I'd put it on a 8x8 and there'd be absolutely NO reason what so ever for a texture map smaller in size.  :whistle: