#### Archived

This topic is now archived and is closed to further replies.

# Color Buffer

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

## Recommended Posts

*noob question* I never really learned to much about coloring objects and text other than the basics, and what do you know, I have a problem. I want to color some text (bitmap font) on my screen. I call glColor3f(..); and nothing changes. I got it to work once (in a different program, coloring text though) but the problem was all my objects with textures turned a shade of red as well. I know this is probably very simple to fix, but just as well, any help? Thanks.

##### Share on other sites
Anyone at all? glColor3f(); is simply not functioning...I''ve tried calling it nearly everywhere, the text does not change color at all.

##### Share on other sites
Is the text drawn as textured quads or do you draw it with glBitmap?

For textures, make sure the texture combiners are actually set to use the primary color when combining the final color. If it''s, for example, GL_REPLACE, then you can call glColor as much as you want, the primary color is never going to affect final color.

For glBitmap, make sure you set the color before setting raster position. The raster color is copied from the primary color when the raster position is set, and if you need to change the color, you need to set the raster position again to update the raster color.

And also make sure you disable all states you don''t need/want.

If this doesn''t help, you better provide some more information about the problem, and code of course.

##### Share on other sites
I am using bitmap fonts...I managed to change the color with glColor4f(). However, my textured quads also change that color after the second frame is rendered. I draw the textured quads first, then the colored text. It looks fine for about half a second then the textured quads turn blue with the text. Do I need to clear the color buffer more than once? I don''t think I am doing the right thing...I change the color of the text, like I said, with glColor, but once the second frame is rendered everything is that color. Any help? (and btw, thanks for your reply, brother bob)

##### Share on other sites
OpenGL is a state machine. When you set a state it remains set until you change it again. Colour is one of these states. When you set the colour to blue (or whatever) every object rendered after that will be coloured blue until you change the colour again. So what you want to do is:
// set the colour back to whiteglColor3f(1, 1, 1);// render the quadsrenderTexturedQuads();// set the colour to whateverglColor3f(r, g, b);// render the textrenderText();

You shouldn''t be needing to use glColor4f. glColor3f should work fine.

Enigma

Thanks.

• 10
• 15
• 14
• 18
• 15