Thanks for that Morbo, I'll stop derailing colik's thread now and let you get back to crushing puny humans ;)
power of 2 textures limitation. How to bypass it?
If the card doesn't support textures large enough for the image you want to display, you have to break it into several textures and then make several triangles (or quads) and set the uv coordinates just right to display the image correctly.
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
Another solution is to have the code resize the textures for you, before generating the the OpenGL texture.
Load the image and the get its dimensions (lWidthPixels, lHeightPixels). Then, get the max texture dimensions supported by OpenGL. Then, calculate:
Then you create a temporary bitmap of that size, blit your loading image onto it, and convert that bitmap to the OpenGL texture. A few hoops to jump through, but it works without any OpenGL extensions.
Nehe's IPicture basecode does exactly this. Download http://nehe.gamedev.net/counter.asp?file=files/misc/nehe_ipicture.zip and see the function BuildTexture in the file NeHe_IPicture.cpp
Note Nehe's code uses Windows-only stuff, so if you're using something else, you'll have to rewrite some of it.
Brian
Load the image and the get its dimensions (lWidthPixels, lHeightPixels). Then, get the max texture dimensions supported by OpenGL. Then, calculate:
// Resize Image To Closest Power Of Two if (lWidthPixels <= glMaxTexDim) // Is Image Width Less Than Or Equal To Cards Limit lWidthPixels = 1 << (int)floor((log((double)lWidthPixels)/log(2.0f)) + 0.5f); else // Otherwise Set Width To "Max Power Of Two" That The Card Can Handle lWidthPixels = 1 << (int)floor((log((double)glMaxTexDim)/log(2.0f)) + 0.5f); if (lHeightPixels <= glMaxTexDim) // Is Image Height Greater Than Cards Limit lHeightPixels = 1 << (int)floor((log((double)lHeightPixels)/log(2.0f)) + 0.5f); else // Otherwise Set Height To "Max Power Of Two" That The Card Can Handle lHeightPixels = 1 << (int)floor((log((double)glMaxTexDim)/log(2.0f)) + 0.5f);
Then you create a temporary bitmap of that size, blit your loading image onto it, and convert that bitmap to the OpenGL texture. A few hoops to jump through, but it works without any OpenGL extensions.
Nehe's IPicture basecode does exactly this. Download http://nehe.gamedev.net/counter.asp?file=files/misc/nehe_ipicture.zip and see the function BuildTexture in the file NeHe_IPicture.cpp
Note Nehe's code uses Windows-only stuff, so if you're using something else, you'll have to rewrite some of it.
Brian
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement