Font Textures and Blending in Colours

Started by
1 comment, last by sckoobs 20 years, 5 months ago
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.
Advertisement
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
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?

This topic is closed to new replies.

Advertisement