Archived

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

Font Textures and Blending in Colours

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
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?

Share this post


Link to post
Share on other sites