Jump to content
  • Advertisement
Sign in to follow this  

Lighting disable issue

This topic is 2728 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!