#### Archived

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

# Font Textures and Blending in Colours

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

## Recommended Posts

I''m attempting to make a font module that allows changing of the font colour, I have partially achieved this by using a font image that has white letters on a black background and using the NeHe Bitmap font method, for quads textured with the font in a display list. I was making the black pixels fully transparent using:
	// set the blending function
glBlendFunc(GL_SRC_ALPHA, GL_ONE);

Now I have added the glTexEnv calls (r, g and b are passed as paramaters to the host function):
	// setup the font colour variables to be passed to texEnv
float rgba[4] = {(float)((1.0f / 255) * r), (float)((1.0f / 255) * g), (float)((1.0f / 255) * b), 1.0f};

// set the texture environment using the pre-calculated rgb values
glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, rgba);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_BLEND);

This however turns the black pixel background to white meaning it is not occluded now. I''m relatively new to using texture blending modes so could someone tell me what I have to do/what I''m doing wrong? Thanks in advance.

##### Share on other sites
I use

glBlendFunc(GL_ONE,GL_ONE_MINUS_SRC_ALPHA);

in the font printing function and set the colour

via

glColor3f(1.0f,0.0f,0.0f);

before calling the print function.. this allows me to use the black and white font bitmap and draw it in any colour (including BLACK)..

Jumpman - Under Construction

##### Share on other sites
Yes... that was always an alternative to the way I had mentioned - thanks Jumpman, however, for the sake of completeness and so I know it actually *can* be done, can anyone tell me how to do it the glTexEnv way?

1. 1
2. 2
3. 3
4. 4
Rutin
17
5. 5

• 10
• 11
• 37
• 12
• 12
• ### Forum Statistics

• Total Topics
631414
• Total Posts
2999958
×