I’m writing a small 3d engine in Dev-C++ for Win32 and i finally got it to use the ARB_Multitexture extension for the lightmaps & textures. Before, I was using a blend function to overlap the texture and the lightmap.
The ARB_Multitexture extension works well, except for one thing: it seems to be affecting any drawing routines done after it (ie: models). The way it is affecting them is by changing the tint and brightness. I noticed that the Frames Per Second counter, which should be displayed as pure white (there is a glColor3f( 1.0, 1.0, 1.0 ); right above the drawing routine) was actually displayed as a dark green with ARB_Multitexturing but with the blending function, it came out pure white. The models are also darkened and tinted when ARB_Multitexturing is used.
Is there something i should do to turn it off before i exit the routine? Or some extra command i should give? Please help.
Some code:
void GamePlay :: drawLeaf ( int index, int cluster )
{
int leafCluster = bsp.bsp_leafs[ index ].cluster;
if( !( bsp.bsp_visdata.vecs[ cluster * bsp.bsp_visdata.sz_vecs + leafCluster / 8 ] & ( 1 << ( leafCluster & 7 ) ) ) && ( cluster > 0 ) )
return;
for( int i = 0; i < bsp.bsp_leafs[ index ].n_leaffaces; i++ )
{
BSP_Face & currFace = bsp.bsp_faces[ bsp.bsp_leaffaces[ bsp.bsp_leafs[ index ].leafface + i ].face ];
// old blend method, begin
/*
glBindTexture( GL_TEXTURE_2D, textureArray[ bsp.texturesDirEntry.numElements + currFace.lm_index ] );
glBegin( GL_TRIANGLES );
for( int j = 0; j < currFace.n_meshverts; j++ )
{
glTexCoord2fv( bsp.bsp_vertexes[ bsp.bsp_meshverts[ currFace.meshvert + j ].offset + currFace.vertex ].texcoord[ 1 ] );
glVertex3fv( bsp.bsp_vertexes[ bsp.bsp_meshverts[ currFace.meshvert + j ].offset + currFace.vertex ].position );
}
glEnd( );
glEnable( GL_BLEND );
glBlendFunc( GL_DST_COLOR, GL_ZERO );
glBindTexture( GL_TEXTURE_2D, textureArray[ currFace.texture ] );
glBegin( GL_TRIANGLES );
for( int j = 0; j < currFace.n_meshverts; j++ )
{
glTexCoord2fv( bsp.bsp_vertexes[ bsp.bsp_meshverts[ currFace.meshvert + j ].offset + currFace.vertex ].texcoord[ 0 ] );
glVertex3fv( bsp.bsp_vertexes[ bsp.bsp_meshverts[ currFace.meshvert + j ].offset + currFace.vertex ].position );
}
glEnd( );
glDisable( GL_BLEND );
*/
// old blend method, end
glActiveTextureARB(GL_TEXTURE1_ARB);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, textureArray[ currFace.texture ]);
glActiveTextureARB(GL_TEXTURE0_ARB);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, textureArray[ bsp.texturesDirEntry.numElements + currFace.lm_index ]);
glBegin( GL_TRIANGLES );
for( int j = 0; j < currFace.n_meshverts; j++ )
{
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, bsp.bsp_vertexes[ bsp.bsp_meshverts[ currFace.meshvert + j ].offset + currFace.vertex ].texcoord[ 1 ][ 0 ], bsp.bsp_vertexes[ bsp.bsp_meshverts[ currFace.meshvert + j ].offset + currFace.vertex ].texcoord[ 1 ][ 1 ] );
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, bsp.bsp_vertexes[ bsp.bsp_meshverts[ currFace.meshvert + j ].offset + currFace.vertex ].texcoord[ 0 ][ 0 ], bsp.bsp_vertexes[ bsp.bsp_meshverts[ currFace.meshvert + j ].offset + currFace.vertex ].texcoord[ 0 ][ 1 ] );
glVertex3fv( bsp.bsp_vertexes[ bsp.bsp_meshverts[ currFace.meshvert + j ].offset + currFace.vertex ].position );
}
glEnd( );
}
}