Thanks for the tip about GL_MODULATE. This moves me forward, but I still have the funny color problem I mentioned. The code for my test is below. I paint the texture, which has yellow-green stuff on a black background (actually it is the NeHe logo wallpaper), then put a red square on it. I wait a bit (so I can see what happened) then call the function again.
The first time I call drawGLScene() I see what I expect, a red square on a yellow-green pattern. The next time, and thereafter, the yellow-green of the NeHe logo has been changed to red on black. If instead of red I draw a green square, the texture color changes to green on black. But if I draw a blue square the texture disappears.
Can you explain what is happening? I’m baffled.
Gib
int drawGLScene( GLvoid )
{
float acolor[4] = {1.0,1.0,1.0,1.0};
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity( );
glTranslatef( 0.0f, 0.0f, -2.0f );
glEnable( GL_TEXTURE_2D );
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, acolor);
glBindTexture( GL_TEXTURE_2D, texture[0] );
glBegin( GL_QUADS ); /* Start Drawing A Textured Quad */
glTexCoord2f( 0.0f, 3.0f ); glVertex3f( -1.1f, -1.1f, 0.0f );
glTexCoord2f( 3.0f, 3.0f ); glVertex3f( 1.1f, -1.1f, 0.0f );
glTexCoord2f( 3.0f, 0.0f ); glVertex3f( 1.1f, 1.1f, 0.0f );
glTexCoord2f( 0.0f, 0.0f ); glVertex3f( -1.1f, 1.1f, 0.0f );
glEnd( );
glDisable( GL_TEXTURE_2D );
glDisable(GL_DEPTH_TEST);
glEnable( GL_BLEND );
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
glColor4f(1.0f, 0.0f, 0.0f, 1.0f);
glBegin( GL_QUADS );
glVertex3f( -0.5f, -0.5f, 0.0f );
glVertex3f( 0.5f, -0.5f, 0.0f );
glVertex3f( 0.5f, 0.5f, 0.0f );
glVertex3f( -0.5f, 0.5f, 0.0f );
glEnd( );
glDisable(GL_BLEND);
glEnable(GL_DEPTH_TEST);
SDL_GL_SwapBuffers( );
}