views:

131

answers:

2

This is just a quick question before I dive deeper into converting my current rendering system to openGL. I heard that textures needed to be in base2 sizes in order to be stored for rendering. Is this true?

My application is very tight on memory, but most of the bitmaps are not a perfect square. Does storing non-base 2 textures waste extra memory?

Thanks.

+1  A: 

It's true depending on the OpenGL ES version, OpenGL ES 1.0/1.1 have the power of two restriction. OpenGL ES 2.0 doesn't have the limitation, but it restrict the wrap modes for non power of two textures.

Creating bigger textures to match POT dimensions does waste texture memory.

Matias Valdenegro
So there's absolutely no way to render a non power of two sized bitmap with openGL without wasting memory? That's annoying. Oh well, glad I didn't start overhauling my code yet.
GuyNoir
With OpenGL ES 1.0/1.1, no.
Matias Valdenegro
By the way, you should know that OpenGL ES and OpenGL doesn't have the same limitations, OpenGL 2.0 and beyond supports NPOT textures directly.
Matias Valdenegro
Alright, thanks.
GuyNoir
A: 

No, it must be a 2base. However, you can get around this by adding black bars to the top and/or bottom of your image, then using the texture coordinates array to restrict where the texture will be mapped from your image. For example, lets say you have a 13 x 16 pixel texture. You can add 3 pixels of black to the right side then do the following:

static const GLfloat texCoords[] = {
        0.0, 0.0,
        0.0, 13.0/16.0,
        1.0, 0.0,
        1.0, 13.0/16.0
    };

Now, you have a 2base image file, but a non-2base texture. Just make sure you use linear scaling :)

Ginamin
The problem here is that it wastes texture memory; something that I am very pressed for with my application.
GuyNoir