Sorry, I thought my problem would be obvious with what I said before, but maybe it is more complicated than I hoped.
Since my initial post, I wrote a test program using the same code as I have already posted (without any calls to glTexEnv*) without the rest of drawing code (that draws 3D models and a text overlay).
This test program correctly displayed the texture. If I call glColor3f, instead of making the entire screen (i.e. the texture that covers the entire screen) that color, it shades it that color. The GL_BGR is correct for how SDL loads .bmp textures.
So, it must be something that is set in the other parts of the rendering that is interfering with the drawing of the texture. Or, perhaps, I am drawing things in the wrong order?
With this thought in mind, I remove all other rendering from my main loop except for the code which renders the full-viewport textured quad. Unfortunately, the problem persists.
Clearly, the texture is there and displayed, since if I modify the glVertex* calls, different segments of the screen are covered by the quad.
Initialization:
int video::load_texture(void)
{ SDL_Surface* tex_image=NULL;
if ((tex_image = SDL_LoadBMP("nehe.bmp")))
{ glEnable(GL_TEXTURE_2D);
glGenTextures(1, &debug_tex);
glBindTexture(GL_TEXTURE_2D, debug_tex);
glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glTexImage2D( GL_TEXTURE_2D, 0, 3, tex_image->w, tex_image->h, 0, GL_BGR,
GL_UNSIGNED_BYTE, tex_image->pixels );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
printf("loaded image!
");
}
else
{ printf("couldn't load image!
");
}
if (tex_image) SDL_FreeSurface(tex_image);
}
Each frame:
int video::draw(void)
{ glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
//glDisable(GL_BLEND);
glDisable(GL_LIGHTING);
glEnable(GL_TEXTURE_2D);
glBindTexture( GL_TEXTURE_2D, debug_tex );
glBegin(GL_QUADS);
//glTexCoord2d(0.0,0.0);
glTexCoord2f( 0.0f, 1.0f); glVertex3f(-1.0f, -1.0f, 1.0f);
//glTexCoord2d(0.0,scale_height);
glTexCoord2f( 1.0f, 1.0f); glVertex3f( 1.0f, -1.0f, 1.0f);
//glTexCoord2d(scale_width,scale_height);
glTexCoord2f( 1.0f, 0.0f); glVertex3f( 1.0f, 1.0f, 1.0f);
//glTexCoord2d(scale_width,0.0);
glTexCoord2f( 0.0f, 0.0f); glVertex3f(-1.0f, 1.0f, 1.0f);
glEnd();
glDisable(GL_TEXTURE_2D);
return 1;
}
If there are no mistakes in the code above, I suspect other glTexEnv* properties are being set somewhere else (in my font drawing code, perhaps) that are affecting the texture mapping but I do not know what they could be.