Jump to content
  • Advertisement
Sign in to follow this  
colik

power of 2 textures limitation. How to bypass it?

This topic is 4969 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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 :)

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!