When i use
glTexEnvfv( GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, color );
its affect on fragments color only when called first time. For example, i have two functions:
//texture prepare function
{
glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE );
glTexEnvf( GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_REPLACE );
}
//rendering function
{
glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_vertexBufferID );
glBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, m_indexBufferID );
glVertexPointer( COORD_PER_VERTEX, GL_FLOAT, 0, (char *)NULL );
glNormalPointer( GL_FLOAT, 0, (char *)NULL + m_verticesQuantity * COORD_PER_VERTEX * sizeof( float ) );
glTexCoordPointer( COORD_PER_TEXTURE, GL_FLOAT, 0,
(char *)NULL
+ m_verticesQuantity * COORD_PER_VERTEX * sizeof( float )
+ m_verticesQuantity * COORD_PER_NORMAL * sizeof( float )
+ m_verticesQuantity * COORD_PER_TEXTURE * sizeof ( float ) );
glDrawRangeElements( PRIMITIVE_TYPE, startIndex, endIndex, count, dataType, ( INDEX_TYPE* )NULL + startIndex );
}
when i call these functions, binded texture is applying on the geometry. This work correct.
Also, i have third function, where i change GL_TEXTURE_ENV_COLOR and source for operand0:
changeColor( int c )
{
const GLfloat cf[] = { cg, cg, cg, cg };
glTexEnvfv( GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, cf );
glTexEnvf( GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_CONSTANT );
}
when i call changeColor( c0 ) i suppose, that instead texture i will see colored triangle. When i use this function first time, it works correct. Triangle color became c0. But when i call this function second time with another color, nothing changes. Triangles color stays c0, but i’ve just called changeColor( c1 ). What is wrong?