Hello,
this should be a fairly basic question but I’m having a hard time finding any answers on the interwebs.
I’m drawing a model, providing a texture as well as a color array, but I don’t understand how the two are being combined.
Is there some parameter where you set this up? I was assuming they’d be multiplied, but the results look fairly random, except when the texture is all white.
// Enable alpha blending
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
// Enable Vertex and Texture pointers
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
...
// vertices
glVertexPointer(3, GL_FLOAT, 0, cur->GetVertexBuffer() );
// texture
glEnableClientState( GL_TEXTURE_COORD_ARRAY );
currentTexID = cur->GetGLTextureID();
glBindTexture(GL_TEXTURE_2D, cur->GetGLTextureID());
glEnable(GL_TEXTURE_2D);
glTexCoordPointer(2, GL_FLOAT, 0, cur->GetTextureCoordBuffer());
// color array
glEnableClientState( GL_COLOR_ARRAY );
glColorPointer( 4, GL_FLOAT, 0, cur->GetColorBuffer() );
// lighting
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_COLOR_MATERIAL);
glEnableClientState( GL_NORMAL_ARRAY );
glNormalPointer( GL_FLOAT, 0, cur->GetNormalBuffer() );
// draw it
glDrawArrays(GL_TRIANGLES, 0, cur->GetNumTriangles()*3 );