Font colour problem

Started by
3 comments, last by Biax 19 years, 3 months ago
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?
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.
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 renderingglPushAttrib(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 beforeglPopAttrib();

Another thing it could be is you don't disable lighting before rendering your fonts.
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

This topic is closed to new replies.

Advertisement