Missing some Initialization

I am highlighting an object that uses a texture.

Initialize ()
{

glEnable(GL_DEPTH_TEST);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
}

//highlighting code
glLineWidth(6);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
DrawObject();
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glLineWidth(1);
DrawObject();

This code works fine except that the highlighting is very settle. Default line color is used.
I added three lines of code to fix the problem
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); (1)
glLineWidth(6);
glColor3f(1.0f,0.0f,0.0f); (2)
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
DrawObject();

glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); (3)
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glLineWidth(1);
DrawObject();

It works as long as I stay on that scene. When I click the highlighted item, I enter a different scene and when I come back the highlighting part is dark (surrounding of my object is dark).
I can’t figure out what is wrong.

clogon

Hi,
Have you tried to set
glDisable(GL_TEXTURE_2D) ? I think lines are
also affected by textures and so perhaps this could be the problem.
Phil

Thanks Phil for your help. glDisable(GL_TEXTURE_2D) didn’t change anything but then I started to disable different thing before drawing the line. It works when I disable glDisable(GL_LIGHTING) . I still don’t know why.

Originally posted by phil_24284:
Hi,
Have you tried to set
glDisable(GL_TEXTURE_2D) ? I think lines are
also affected by textures and so perhaps this could be the problem.
Phil