Hi!
I have created 2 textures. Inside rendering function I want to show 3 quads. First two should simply show loaded textures and the last one should show one texture on the other. This is a rendering code:
void RenderScene( HDC hDC )
{
static FLOAT wrap = 0;
glClearColor( 0.0f, 0.0f, 1.0f, 1.0f );
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glLoadIdentity();
glColor3ub( 255, 255, 255 );
glEnable( GL_TEXTURE_2D );
// Show FIRST texture - single
glBindTexture( GL_TEXTURE_2D, uiTextureIDs[ 0 ] );
glBegin( GL_QUADS );
glTexCoord2f( 0.0f, 0.0f );
glVertex3f( 1.0f, 0.0f, 0.0f );
glTexCoord2f( 1.0f, 0.0f );
glVertex3f( 6.0f, 0.0f, 0.0f );
glTexCoord2f( 1.0f, 1.0f );
glVertex3f( 6.0f, 5.0f, 0.0f );
glTexCoord2f( 0.0f, 1.0f );
glVertex3f( 1.0f, 5.0f, 0.0f );
glEnd();
// Show SECOND texture - single
glBindTexture( GL_TEXTURE_2D, uiTextureIDs[ 1 ] );
glBegin( GL_QUADS );
glTexCoord2f( 0.0f, 0.0f );
glVertex3f( 7.0f, 0.0f, 0.0f );
glTexCoord2f( 1.0f, 0.0f );
glVertex3f( 12.0f, 0.0f, 0.0f );
glTexCoord2f( 1.0f, 1.0f );
glVertex3f( 12.0f, 5.0f, 0.0f );
glTexCoord2f( 0.0f, 1.0f );
glVertex3f( 7.0f, 5.0f, 0.0f );
glEnd();
// Show FISRT texture on SECOND one - multitexture
pcEngine3D->glActiveTextureARB( GL_TEXTURE0_ARB );
glEnable( GL_TEXTURE_2D );
glBindTexture( GL_TEXTURE_2D, uiTextureIDs[ 1 ] );
pcEngine3D->glActiveTextureARB( GL_TEXTURE1_ARB );
glEnable( GL_TEXTURE_2D );
glBindTexture( GL_TEXTURE_2D, uiTextureIDs[ 0 ] );
glBegin(GL_QUADS);
pcEngine3D->glMultiTexCoord2fARB( GL_TEXTURE0_ARB, 0.0f, 0.0f );
pcEngine3D->glMultiTexCoord2fARB( GL_TEXTURE1_ARB, 0.0f-wrap, 0.0f );
glVertex3f( 3, 6, 0 );
pcEngine3D->glMultiTexCoord2fARB( GL_TEXTURE0_ARB, 1.0f, 0.0f );
pcEngine3D->glMultiTexCoord2fARB( GL_TEXTURE1_ARB, 1.0f-wrap, 0.0f );
glVertex3f( 10, 6, 0);
pcEngine3D->glMultiTexCoord2fARB( GL_TEXTURE0_ARB, 1.0f, 1.0f );
pcEngine3D->glMultiTexCoord2fARB( GL_TEXTURE1_ARB, 1.0f-wrap, 1.0f );
glVertex3f( 10, 11, 0);
pcEngine3D->glMultiTexCoord2fARB( GL_TEXTURE0_ARB, 0.0f, 1.0f );
pcEngine3D->glMultiTexCoord2fARB( GL_TEXTURE1_ARB, 0.0f-wrap, 1.0f );
glVertex3f( 3, 11, 0);
glEnd();
glDisable( GL_TEXTURE_2D );
wrap += 0.0015f;
SwapBuffers( hDC );
}
The problem is when I have added the code needed to show the last quad first two became corrupted and show the first texture ( that one connected with GL_TEXTURE0_ARB ). When I remove this code both textures are shown correctly
I have met this problem some time ago but I don’t remember the solution