glColor3f and ARB multitexturing not working right together!

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);
	}
}

Lots of bugs in the code.
Texture enables are per texture unit.
See comments:

void ModelFile::sketch(void)
{
    glDisable(GL_LIGHTING);
    glDisable(GL_TEXTURE_2D); // Which texture unit is active? See bindTexture()
    glDisable(GL_TEXTURE0_ARB); // Error
    glDisable(GL_TEXTURE1_ARB); // Error
    glDisable(GL_BLEND);
    glEnable(GL_COLOR_MATERIAL); // Useless! Lighting is off.
    glBegin(GL_LINE_STRIP);
    glColor3f(1,1,1); // Constant for whole primitive, put outside begin-end!
    for(int i=0; i<(int)verticies.size(); i++)  
    {
        glVertex3f(verticies[i].vertex[0],verticies[i].vertex[1],verticies[i].vertex[2]);
        // Use glVertex3fv if the struct allows: glVertex3f(verticies[i].vertex);
    }
    glEnd();
}

void awf::SketchForDL(void)
{
    int index = 0;

    awfDL = glGenLists(1);
    glNewList(awfDL,GL_COMPILE);
    glDisable(GL_LIGHTING); // Each display list disables 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); // Was missing.
        glBindTexture(GL_TEXTURE_2D, tex2);
    }else{
        // If you run through these paths in the same scene, you worked on the wrong unit.
        glActiveTextureARB(GL_TEXTURE0_ARB); // Was missing
        glEnable(GL_TEXTURE_2D);
        glBindTexture(GL_TEXTURE_2D,tex1);
    }
}

I made the changes, but my colors are still wrong.

This simply means there are remaining bugs. Ensure you have all your texures disabled when you need colors alone.

How do I go about disabling the ARB textures though? If I call glDisable(GL_TEXTURE_2D); that does not do anything to help my bug.