PDA

View Full Version : Nonsquare texturemaps?



clintsinger
10-07-2004, 05:39 PM
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

hmwill
10-07-2004, 08:21 PM
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

bentlegen
10-08-2004, 11:38 AM
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

www.rzr.online.fr
10-18-2005, 09:22 AM
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 ?

debinair
04-23-2012, 01:43 AM
@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 );