rectangular bitmaps

I’ve seen in games before where textures have been used that did not necessarily have dimensions that were powers of 2. Also, I’ve seen many where the height and width differ.

I’m having trouble getting this to work for me. OpenGL tells me (as do several other sources), that the images must have dimensions that are powers of 2, and that the height and width must be equal.

So my question is how is this situation handled. How do artists make rectangular images and use them in OpenGL? Or rather, how does the programmer typically solve this? Do they stretch the image to the next largest power of 2 and stretch it to make it square? Is there some OpenGL state I have to enable for this to work? Or is there some OpenGL function that loads the image differently?

Any help would be greatly appreciated.
Thanks!

Up until OpenGL 1.4 the image width and height had to be a power of 2 (but not equal). You could create for example a flag 128x64 pixels. Anyway this is changing I believe with OpenGL 1.5 and we can finally have any texture size we want. Cheers.

hmm… See, I still seem to recall seeing some images that had sides that weren’t a power of 2, like 256x192… typically they were still multiples of 2.

I could be wrong though.

Thanks for your help though!

If you use the gluBuild2DMipmaps function, it automatically rescales textures for you, and feeds them as power-of-2 textures to the gfx card.

Maybe that helps you.

Jan.

Well, gluBuild2DMipmaps actually is useful for building mipmaps, but that’s a good idea though; distant rendered textures would be powers of 2.

Anyway, here were my findings: I can render textures that are rectangular, and they don’t both need to be powers of 2. I found that as long as one dimension (the larger, in this case) was a power of 2, it worked. If neither was a power of two, the results were unpredictable (sometimes it worked, sometimes it didn’t).

Correction: Jan, you were right… the reason it worked for me was I AM using gluBuild2DMipmaps… the image I was trying to work this on was a background image for my command console, which I didn’t think I was calling gluBuild2DMipmaps on (considering you would only see the texture up close).

But with gluBuild2DMipmaps it works just fine (as long as one of the dimensions is a power of 2; otherwise it can give some weird results).

Thanks guys.