I have two textures that I am attempting to blend together, in the demo application I am trying to set the vertex color of the primitive that I am drawing with ‘glColor4ub(255, 0, 0, 255);’ So the primitive should be red when being rendered.
The first texture is red, but the second texture is not and instead remains as full white (255, 255, 255). So I basically want that second texture to be red as the first one.
I’ve been looking into various ways to blend but all have failed and at this point I am stumped. I’ve also tried GL_MODULATE in place of GL_ADD but that instead makes the final result way too dark.
Here is the code to draw and display the multi-textured polygon:
void render( void )
{
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
glTranslatef( 0.0f, 0.0f, -4.0f );
//
// STAGE 0
//
glActiveTextureARB( GL_TEXTURE0_ARB );
glColor4ub(255, 0, 0, 255);
glBindTexture( GL_TEXTURE_2D, g_textureID_0 );
//
// STAGE 1
//
glActiveTextureARB( GL_TEXTURE1_ARB );
glColor4ub(255, 0, 0, 255);
glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_ADD );
glBindTexture( GL_TEXTURE_2D, g_textureID_1 );
glEnable( GL_TEXTURE_2D );
//
// Render our quad with two sets of texture coordinates...
//
glBegin( GL_QUADS );
{
glMultiTexCoord2fARB( GL_TEXTURE0_ARB, 0.0f, 0.0f );
glMultiTexCoord2fARB( GL_TEXTURE1_ARB, 0.0f, 0.0f );
glVertex3f( -1.0f, -1.0f, 0.0f );
glMultiTexCoord2fARB( GL_TEXTURE0_ARB, 0.0f, 1.0f );
glMultiTexCoord2fARB( GL_TEXTURE1_ARB, 0.0f, 1.0f );
glVertex3f( -1.0f, 1.0f, 0.0f );
glMultiTexCoord2fARB( GL_TEXTURE0_ARB, 1.0f, 1.0f );
glMultiTexCoord2fARB( GL_TEXTURE1_ARB, 1.0f, 1.0f );
glVertex3f( 1.0f, 1.0f, 0.0f );
glMultiTexCoord2fARB( GL_TEXTURE0_ARB, 1.0f, 0.0f );
glMultiTexCoord2fARB( GL_TEXTURE1_ARB, 1.0f, 0.0f );
glVertex3f( 1.0f, -1.0f, 0.0f );
}
glEnd();
SwapBuffers( g_hDC );
}
Full link to the test application can be found here:
http://www.speedyshare.com/743514512.html
So below are the two textures that I am trying to blend together: