PDA

View Full Version : glTexImage2D subtlety?


w_reade
2003.12.10, 10:17 AM
This worked on Jaguar:


glGenTextures(1, &GLid);
glBindTexture(GL_TEXTURE_2D, GLid);
if (mipmap)
gluBuild2DMipmaps(GL_TEXTURE_2D,
GL_RGBA,
width,
height,
GL_BGRA,
GL_UNSIGNED_INT_8_8_8_8_REV,
buf);
else
glTexImage2D(GL_TEXTURE_2D,
0,
GL_RGBA,
width,
height,
0,
GL_BGRA,
GL_UNSIGNED_INT_8_8_8_8_REV,
buf);


Now, under Panther, it doesn't.

More specifically, glTexImage2D() just produces an opaque white texture, while gluBuild2DMipmaps() still works as expected.

Am I ignoring some subtle requirement somewhere? The textures are all Po2 square...

FCCovett
2003.12.10, 10:45 AM
I think I've seen this problem being addressed in a previous thread, just a few weeks ago. There was a work-around on that thread... if I only could find it.

If I recall it correctly, it has something to do with the OpenGL defaults for the functions, which didn't work right on versions of OS X previous to Panther.

The fix is to set up the correct parameter to override the default setting for that function.

OneSadCookie
2003.12.10, 11:42 AM
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);

(texture min filter defaults to NEAREST_MIPMAP_LINEAR or something equally absurd. Under previous versions of the Mac OS, it was treated as LINEAR if there were no mipmaps. On Panther, it's (correctly) treated as invalid.)

w_reade
2003.12.10, 05:54 PM
Ah, thanks. Fixed now. Cheers.