Jump to content
  • Advertisement
Sign in to follow this  
Biax

OpenGL Font colour problem

This topic is 5079 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

Ive just started OpenGL programming. Ive been developing a console system for a game I've just started making, and I've been working with font output to the screen. The problem I'm having is the text always outputs as very very very dark colours. For instance glColor3f(1,0,0) gives a very dark maroon instead of red, glColor3f(0,1,0) gives a very dark green instead of lime, etc. What am I doing wrong?

Share this post


Link to post
Share on other sites
Advertisement
How are you rendering the text - bitmap fonts or font outlines? Is texturing enabled, is does your texture have RGB colors (if you have bitmap fonts)? Is your blending correct (if you're blending)? More code would help.

Share this post


Link to post
Share on other sites
If texturing is enabled you might get effects like you describe. One way to ensure that the text gets the color you want is to

  1. Disable texturing before rendering the text

  2. Set the color for the text

  3. Draw text

  4. Reenable texturing



Example:

// Stores the color and texture state before the text rendering
glPushAttrib(GL_CURRENT_BIT | GL_TEXTURE_BIT);
glDisable(GL_TEXTURE_2D);
glColor3f( 1.0f, 0.0f, 0.0f);

// Render your text here

// Restores the color and texture state back to what it was before
glPopAttrib();


Share this post


Link to post
Share on other sites
Thanks heaps Mhondoz. I knew it was something like that, I just didn't know exactly, and I didn't know how to do it. It's working fine now =D

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!