Nonsquare texturemaps?

Hi All,

I was wondering if it is possible to use a texture map that is not a power of 2. I have several images of arbitrary size which need to be placed on individual rectangles. I would prefer not to have to doctor the image to be a power of 2 compatible image. If it is possible I would sure appreciate some sample code of how to do it because I am not finding anything on the internet.

Thanks,
Clint

Well, unfortunately you will need to set both width and height to powers of 2 for OpenGL ES. However, width and height do not have to be identical, so textures can be rectangular.

  • HM

Furthermore, just because the texture file dimensions need to be powers of two, doesn’t mean you need to use all that space.

i.e. You could fill a 256 x 256 texture with some 167x233 image, and just be sure to plot your texture vertices appropriately.

Of course, if you want to use texture wrapping, then forget what I just said altogether.

  • Ben

Is it the only way to fill the colorbuffer with texture ?

In the case of a barground image,
Copying a texture to a larger buffer, will eat time and memory,
how comes there is no way to directly copy an image to the colorbuffer ?

@clintsinger: For NPOT texturing you have to set some specific filtering modes i.e.:

glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,GL_CLAMP_TO_EDGE);
glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,GL_CLAMP_TO_EDGE );

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.