I have a rather pesky problem that I can’t seem to fix.
I wrote a program that loads a quake3 bsp file and uses the gl_arb_multitexture extension to render the level (each polygon has a lightmap texture and a regular texture)… my problem is that when i use the multitexturing and then try to render some non-textured polygons and color them with glColor3f() it is almost never the color that i specify.
I call glEnable(GL_COLOR_MATERIAL); and I thought that fixed it but it hasn’t.
If i dont make any calls to the ARB functions and just use the regular GL_TEXTURE_2D then my colors seem to work fine.
I ran the program on my girlfriends computer, and the colors are screwed up there too.
Right now I’m drawing some lines and i call glColor3f(1,1,1); and the lines come out kind of yellowish. There are two textures that I use in my test level - a concrete texture, and a rust texture with dark yellow/red in it. The only thing that I can figure is that glColor3f is getting colors from the ARB texture palette. Unfortunately I have NO idea how opengl does any of this, so any help would be appreciated.
Thanks!
Here ARB multitexturing is on, and the wireframe is yellow, and the boxes are dark colors.
Here is with ARB multitexturing disabled, and rendering a single texture with GL_TEXTURE_2D, the lines are white the way they should be, and the boxes are bright vivid random colors the way they should be.
Code to draw the white lines.
void ModelFile::sketch(void)
{
glDisable(GL_LIGHTING);
glDisable(GL_TEXTURE_2D);
glDisable(GL_TEXTURE0_ARB);
glDisable(GL_TEXTURE1_ARB);
glDisable(GL_BLEND);
glEnable(GL_COLOR_MATERIAL);
glBegin(GL_LINE_STRIP);
glColor3f(1,1,1);
for(int i=0;i<(int)verticies.size();i++)
{
glVertex3f(verticies[i].vertex[0],verticies[i].vertex[1],verticies[i].vertex[2]);
}
glEnd();
}
Code to draw the level.
void awf::SketchForDL(void)
{
int index = 0;
awfDL = glGenLists(1);
glNewList(awfDL,GL_COMPILE);
glDisable(GL_LIGHTING);
int counter = 0;
for(int i=0;i < (int)surfaceData.size();i++)
{
bindTexture(textureData[surfaceData[i].textureIndex].id,
lightmapData[surfaceData[i].lightmapIndex].id);
glBegin(GL_TRIANGLE_FAN);
index = surfaceData[i].baseVertexIndex;
glColor3f(1,1,1);
// Loop through the surfaces
for(int k=0;k<surfaceData[i].vertexSpan;k++) {
texCoords(vertexData[index+k].texturemapCoordinates,
vertexData[index+k].lightmapCoordinates);
vertexData[index+k].origin.Plot();
counter++;
}
glEnd();
}
glEndList();
}
//********************************************
void awf::texCoords(uv coords1,uv coords2)
{
if(multiTexturing) {
glMultiTexCoord2fARB(GL_TEXTURE0_ARB,coords1.u,coords1.v);
glMultiTexCoord2fARB(GL_TEXTURE1_ARB,coords2.u,coords2.v);
}else{
glTexCoord2f(coords1.u,coords1.v);
}
}
//********************************************
void awf::bindTexture(GLuint tex1,GLuint tex2)
{
if(multiTexturing) {
glActiveTextureARB(GL_TEXTURE0_ARB);
glEnable(GL_TEXTURE_2D);
glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
glBindTexture(GL_TEXTURE_2D, tex1);
glActiveTextureARB(GL_TEXTURE1_ARB);
glEnable(GL_TEXTURE_2D);
glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
glBindTexture(GL_TEXTURE_2D, tex2);
}else{
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D,tex1);
}
}