PDA

View Full Version : can't load non power of 2 textures!?



bill2727
07-13-2003, 02:38 PM
I've loaded textures for a long time, and I thought I knew what I was doing, but I'm posting this in beginners since it seems like such a simple problem. I load my texture something like:

glTexImage2D(GL_TEXTURE_2D,0,3,512,256,0,
GL_RGB,GL_UNSIGNED_BYTE,TexFile);

This works just fine, but if I would have substituted say a 200x100 texture file, and put 200 in the place of 512 and 100 in the place of 256, the texture always shows up as white! Note: I've loaded textures with alpha channels, different mipmap levels, different file formats, etc., so I at least somewhat know what I'm doing here. I read ogl can handle any arbitrary texture size, isn't this true?
I'd appreciate anything that would help me resolve this seemingly simple problem.
-bill

Relic
07-13-2003, 03:41 PM
Read: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/opengl/glfunc03_16jo.asp
and: http://oss.sgi.com/projects/ogl-sample/registry/NV/texture_rectangle.txt

bill2727
07-13-2003, 04:37 PM
Wow, I'm suprised. Thanks much... I'll look into using that extension. Its an NV extension, does that mean it won't work with ATI cards?

Relic
07-13-2003, 04:46 PM
Check if your card advertises an extension which allows to use rectangular textures.

A simpler way would be to use gluScaleImage or gluBuild2DMipmaps which itself uses gluScaleImage to scale the textures to the next power of two sizes for you.

bill2727
07-13-2003, 04:54 PM
Alright great.. couldn't be a simpler answer, but I appreciate it cause it would have taken me hours to figure out wtf is going on on my own. I'll see how distorted the textures are using those commands, thx again!

zeckensack
07-13-2003, 05:31 PM
ATI ICDs advertise EXT_texture_rectangle since Cat 3.2, I think. Good news: the enumerant values are the same as for NV_texture_rectangle.

A simpler way would be to use gluScaleImage or gluBuild2DMipmaps which itself uses gluScaleImage to scale the textures to the next power of two sizes for you.Note that glu functions aren't aware of GL extensions, and don't understand packed pixels and compressed textures.