Advertisement

power of 2 textures limitation. How to bypass it?

Started by February 10, 2005 04:31 AM
11 comments, last by BriTeg 19 years, 7 months ago
quote from Nehe's tutorial 6
Quote: The image height and width MUST be a power of 2. The width and height must be at least 64 pixels, and for compatability reasons, shouldn't be more than 256 pixels. If the image you want to use is not 64, 128 or 256 pixels on the width or height, resize it in an art program. There are ways around this limitation, but for now we'll just stick to standard texture sizes
I am exploring the idea of making a simple picture viewer with a openGL surface in 2d ortho projection... and would like to be able to load pictures of any given size. I couldnt find anything about the "ways around this limitation" he's speaking of by googling around so could anyone pass me a few pointers? thanks
The GL_ARB_TEXTURE_RECTANGLE extension.
Advertisement
wow that was a quick reply. Thanks :)
Or if you have a good graphics card you don't have to do anything thanx to GL_ARB_texture_non_power_of_two that you can find in openGL 2.0
If by chance you don't need to repeat the texture, you can simply reserve a bigger texture (say for a 640x480 texture you reserve 1024x512) and use a scale factor into the texture matrix so that the [0,1] range maps to the correct sub-texture range.
thanks for the leads it was very useful and instructive.
Advertisement
even easier is just gluBuild2DMipmaps(). I havent checked this for sure but I think that this function resizes to powers of two before it passes the data to OpenGL

see lesson 7
no it doesn't.
I always thought it did, or is it something that was supposed to work in that way but just doesn't? To quote from The Blue Book, Chapter 6: "If the dimensions of the input image are not powers of two, then the image is scaled so that both the width and height are powers of two before the mipmaps are generated.".

Not wanting to be cocky here, just want some clarification :)
--
Cheers,
Darren Clark
Quote: Original post by eSCHEn
I always thought it did, or is it something that was supposed to work in that way but just doesn't? To quote from The Blue Book, Chapter 6: "If the dimensions of the input image are not powers of two, then the image is scaled so that both the width and height are powers of two before the mipmaps are generated.".

Not wanting to be cocky here, just want some clarification :)


You're correct: gluBuild2DMipmaps() calls gluScaleImage() if the image is not power of 2...in accordance with the prophecies, er, specs.

This topic is closed to new replies.

Advertisement