views:

42

answers:

2

I'm new at OpenGL and I can't find out how to do this:
I want to render a letter and be able to change it's color, so I have a texture with the letter on a transparent background. I managed to render it using this code:

glEnable(GL_BLEND)
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)  

But that renders the letter in black, as it's on the texture. How can I render it with the color setted with glColor4f?

+1  A: 

Have you been messing with glTexEnv? If you did, call :

glTexEnv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE)

and that will restore the default behaviour, which is to multiply the texture color with the vertex color.

Matias Valdenegro
Well, if the default behaviour is to multiply the texture color with the vertex color then I should have made my texture white instead of black, right?
Damian
Yes, but depends on what you passed to glColor4f.
Matias Valdenegro
Yes, that was the problem, I changed the texture color to white and now works as expected.
Damian
A: 

There are a couple of other possibilities. One would be to put the shape of the letter into the stencil buffer, and then draw a quad in your preferred color. Another would be to draw your text in light grey, and use lighting to have it displayed in the color you want.

Jerry Coffin