Sign in to follow this  
Antar3s

Lighting disable issue

Recommended Posts

I'm displaying text in my OGL 3D application using glutBitmapCharacter.
Text should be white and not affected by lights, so I disable them in the while. However, lights affects text color even when they are turned off. Why it happens?
I tried enabling and disabling GL_COLOR_MATERIAL, with no success.

Here's the code for text drawing.

First, I set the projection matrix and disalbe lighting:
void InterfaceHandler::beginInterfaceDrawing()
{
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
gluOrtho2D(0, windowWidth, windowHeight, 0);
glDisable(GL_LIGHTING);
}

Then, print text on screen:
void InterfaceHandler::printLabel(string label, uint labelX, uint labelY)
{
glMatrixMode(GL_MODELVIEW);

glPushMatrix();
glLoadIdentity();
glColor3fv(Color::WHITE);
glRasterPos2i(labelX, labelY);
for (string::iterator i = label.begin(); i != label.end(); ++i)
{
char c = *i;
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, c);
}
glPopMatrix();
}

At last, I reset the projection matrix and turn lights on:
void InterfaceHandler::endInterfaceDrawing()
{
glEnable(GL_LIGHTING);
glMatrixMode(GL_PROJECTION);
glPopMatrix();
}

What's wrong?

Thanks all.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this