Advertisement

Texturing on a rectangle

Started by April 02, 2005 12:25 PM
5 comments, last by HelplessFool 19 years, 7 months ago
Hello, I have refered to NEHE example 6 about texturizing quads, but what I plan on doing is just texturing a quad on just one side. Problem I am having is that the image I have is a rectangle with a width of 576 pixels, and height of 360 pixels. I load the image and all that and I assume the area of concern for this is within this code: glTexCoord2f(0.0f, 0.0f); glVertex2f(-1.0f, -1.0f); glTexCoord2f(1.0f, 0.0f); glVertex2f( 1.0f, -1.0f); glTexCoord2f(1.0f, 0.625f); glVertex2f( 1.0f, 1.0f); glTexCoord2f(0.0f, 0.625f); glVertex2f(-1.0f, 1.0f); Is there any sort of formula available to determine the values for both glTexCoord2f and glVertex2f? Or am I doing this wrong? It displays a white square. Thankyou, Jamie
Your texture size is non-power of 2, which means that either the width or the height - or both - isn't 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048 etc. pixels wide.
OpenGL only accepts power of 2 textures (others can be loaded via an extension, but I think that's only for newer cards - but standard only accepts power of 2).
Killers don't end up in jailThey end up on a high-score!
Advertisement
exactly, resize it to 512x256 and it will probobly work just fine.
so far i never use glvertex2f. i think glvertex2f is used to draw to 2D image.
Is there a way to work around the fact that openGL only accepts power of 2 textures?

-Jamie
There are extensions to allow the use of oddly size texutures but you are best to stick to the rule as that is guaranteed.

If texturing 2D planes (sprites) then you could just pad your texture with a dedicated invisible colour.
Advertisement
Quote: Original post by ACSRalphie
Is there a way to work around the fact that openGL only accepts power of 2 textures?

-Jamie


Quote: From Lesson7
I had said in tutorial six there was a way around the 64,128,256,etc limit that OpenGL puts on texture width and height. gluBuild2DMipmaps is it. From what I've found, you can use any bitmap image you want (any width and height) when building mipmapped textures. OpenGL will automatically size it to the proper width and height.

This topic is closed to new replies.

Advertisement