Vern,
The problem is almost definitely mipmap related or glEnable(GL_TEXTURE_2D).
Try to come up with the absolute simplest example. Nearest I can figure is
this one:
This code should produce a white square:
void init() {
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, texObj);
glTexImage(0, …)
}
void loop() {
glBindTexture(GL_TEXTURE_2D, texObj);
drawRect();
}
Changing init() to:
void init() {
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, texObj);
glTexImage(0, …)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
}
should fix it. Here’s the reasoning:
Texture filter information is bound to the texture object. This is unlike
Direct3D where it is bound to the texture unit. GL 3.3 has so-called
"sampler state" objects that resemble DX better and simplify code (e.g. a
user changing texture filtering from bilinear to trilinear would require
glBindTexture()/glTexParameteri() for each and every texture used in the
world with the new state)
If a texture does NOT have mipmaps, then using GL_MIPMAP will produce
white textures. This is because you have to call glTexImage2D() for each
mipmap level first. Most likely, you’re leaving the texture bound and
messing with the properties of it unintentionally. This is an easy error to
make, but to figure that out, you can try binding the zero texture object
after each group:
glBindTexture(GL_TEXTURE_2D, texObj);
glTexImage(0, ....)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glBindTexture(GL_TEXTURE_2D, 0);
Finally, if you are enabling/disabling 2D textures, you should consider how
many cases you really use untextured, and maybe just do
glEnable(GL_TEXTURE_2D) at the start of hte program and never mess with it
again. Let me know if that fixes your issue, or email me a link/project
that I can debug/compile.On Wed, Jan 18, 2012 at 4:48 PM, VernJensen wrote:
**
Asked about this on the OpenGL forums, but no response. But, the problem
is explained pretty clearly in my first post:
http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Number=308630#Post308630
SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org