Hi, i’ve read a few things on lightmaps and how to blend them and they say to do this:
glBlendFunc( GL_ONE, GL_ZERO );
render lightmap
glBlendFunc( GL_DST_COLOR, GL_ZERO );
render textures
but i tried that, and all i see is the lightmaps on the screen… can anyone help me out with what i may be doing wrong? i’m going insane, it doesn’t make any sense why it’s not blending…
some code:
void GamePlay :: drawLeaf ( int index )
{
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 ];
glEnable( GL_BLEND );
glColor4f( 1, 1, 1, 1 );
glBlendFunc( GL_ONE, GL_ZERO );
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 ] );
glVertex3f( bsp.bsp_vertexes[ bsp.bsp_meshverts[ currFace.meshvert + j ].offset + currFace.vertex ].position[ 0 ],
bsp.bsp_vertexes[ bsp.bsp_meshverts[ currFace.meshvert + j ].offset + currFace.vertex ].position[ 2 ],
bsp.bsp_vertexes[ bsp.bsp_meshverts[ currFace.meshvert + j ].offset + currFace.vertex ].position[ 1 ] );
}
glEnd( );
glColor4f( 1, 1, 1, 1 );
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 ] );
glVertex3f( bsp.bsp_vertexes[ bsp.bsp_meshverts[ currFace.meshvert + j ].offset + currFace.vertex ].position[ 0 ],
bsp.bsp_vertexes[ bsp.bsp_meshverts[ currFace.meshvert + j ].offset + currFace.vertex ].position[ 2 ],
bsp.bsp_vertexes[ bsp.bsp_meshverts[ currFace.meshvert + j ].offset + currFace.vertex ].position[ 1 ] );
}
glEnd( );
}
}
void GamePlay :: genTexs ( )
{
Tga24Bit tgaTemp;
string strTemp;
glEnable( GL_TEXTURE_2D );
textureArray = new GLuint [ bsp.texturesDirEntry.numElements + bsp.lightmapsDirEntry.numElements ];
glGenTextures( bsp.texturesDirEntry.numElements + bsp.lightmapsDirEntry.numElements, &textureArray[ 0 ] );
for( int i = 0; i < bsp.texturesDirEntry.numElements; i++ )
{
strTemp = "";
strTemp += bsp.bsp_textures[ i ].name;
strTemp += ".tga";
tgaTemp.loadTGA( strTemp.c_str() );
glBindTexture( GL_TEXTURE_2D, textureArray[ i ] );
glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL );
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, tgaTemp.width, tgaTemp.height, 0, GL_RGB, GL_UNSIGNED_BYTE, tgaTemp.imageData );
tgaTemp.releaseData( );
}
for( int i = 0; i < bsp.lightmapsDirEntry.numElements; i++ )
{
glBindTexture( GL_TEXTURE_2D, textureArray[ bsp.texturesDirEntry.numElements + i ] );
glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, 128, 128, 0, GL_RGB, GL_UNSIGNED_BYTE, bsp.bsp_lightmaps[ i ].map );
}
}