Textures Question

Post: #1
Is it possible to use textures that are non-powers of two in dimension in OGL? I am developing a little app, and noticed that several of my textures were/are showing up pure white when I display them, or else are showing up the currently selected color, but others are showing their textures properly. The only difference I notice upon further examination is that the white rects are all coming from textures that are non-powers of two. So, does that behaviour sound in line with using textures that are non-powers of two, and if so, is there a way to do it anyway?

My texture needs to be 384 x 192. Since it was not working correctly, I went ahead and made it 512x256, and used texture coords to select the area I wanted. Things then seemed to work, so I'm guessing my above guess is what is wrong, but again, is there another fix?


Quote this message in a reply
Posts: 5,143
Joined: 2002.04
Post: #2
That is the most portable way to do what you want.

There is an extension called GL_EXT_texture_rectangle, available on ATI Radeon / GeForce2MX and above, which allows you to do what you want. You use GL_TEXTURE_RECTANGLE_EXT in place of GL_TEXTURE_2D (ie in BindTexture, TexImage2D, &c), and your texture coordinates run (0..width, 0..height) instead of (0..1, 0..1).
Quote this message in a reply
Post: #3
Yes, openGL texture have to be power of 2 dimensions. You can do what onesadcookie said and use the texture rectangle extension or do what you figured out yourself and crop the texture using the texture co-ordinates.

An extension of this approach is to put a whole bunch of different graphics in the same texture and use the texture coordinates to select each graphic. This can sometimes lead to more efficient rendering. This is widely used for font rendering and light mapping.
Quote this message in a reply
Post Reply