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( );
}
}