Original Post
Hey everyone,
I tried to add multitexturing to my little engine.. with success. for testing, a rendered 2 quads with same textures, and added a lightmap to the second. this still works fine, but when i add a third texture to the second quad, the first quad seems to be "darker", as if its affected by the color of the 3 multitextures of the second quad. i think it has something to do with enabling and disabling my texcoord array, so i post my code:
void cGPOpenGL::RenderFace(Ptr<cGPFace> p_pFace)
{
glPushMatrix();
if (!p_pFace->IsValid()) return;
p_pFace->OnUpdate();
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, sizeof(Vec3), &p_pFace->m_lVertices[0].x);
if( p_pFace->UseTextures() )
{
for(Int i=0; i<(Int)p_pFace->m_lTextures.size(); i++)
{
glClientActiveTextureARB(GL_TEXTURE0_ARB+i);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(2, GL_FLOAT, sizeof(Vec3), &p_pFace->m_lTextures[i]->m_lCoords[0].x);
Texture()->Activate(p_pFace->m_lTextures[i]->m_nTexId, i);
}
}
glDrawArrays(GL_TRIANGLE_FAN, 0, (GLsizei)p_pFace->m_lVertices.size());
for(Int i=0; i<(Int)p_pFace->m_lTextures.size(); i++)
{
glClientActiveTextureARB(GL_TEXTURE0_ARB+i);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDisable(GL_TEXTURE_2D);
}
glPopMatrix();
}
important to know: each "face" got 1 list with vertices and a vector with variable amount of lists with texcoords (depends on how many textures you want to use).
"Texture()->Activate(..)" perfoms this (in fact, the texture manager passes the tex data to the renderer:
void cGPOpenGL::ActivateTexture(UInt p_pTexData, Int p_nMulti)
{
glActiveTextureARB(GL_TEXTURE0_ARB+p_nMulti);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, p_pTexData);
}
I hope someone of you can help me
- FDan
[edited by - FDan on January 2, 2004 11:24:05 PM]
[edited by - FDan on January 2, 2004 11:25:06 PM]