Problem with texture mapped fonts


I have a problem with texture mapped fonts. I’m reading a font from file, the backgrund of texture font is black. I use BlendFunc(GL_SRC_ALPHA, GL_SRC_ALPHA). When I render a letter on a black background all is OK, but if I render a letter on some else surface which has else color I see the edges of letter which are used only for antyaliasing (I shouldn’t see them). How to make font like in Quake 3 Arena that has one color and is correctly antyaliased (font color doesn’t depends on colors behind the letter texture)? I have tested diffrent blending options but it gives nothing. The font file is OK. What should I do to make a font like in Quake3?
I’ve checked NeHe’s tutorial but there is else method than I want.

thanks for help


First of all, your blending function is wrong, it should be GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA. Well maybe it’s just a typo…

To get the antialiased fonts right, your texture’s color channel should be totally white. This way you can set the text color with glColor. You can antialias the alpha channel if you want.



I’ve changed the second parameter to GL_ONE_MINUS_SRC_ALPHA but then I see a black color around a letter (all letter texture is opaque). But there is the second problem. When I set the blending to above letters are cutted a little from right side.
Mark J. Kilgard writes about it in his tutorial “A Simple OpenGL-based API for Texture Mapped Text”. He says that I should enable polygon offset by glEnable(GL_POLYGON_OFFSET) and then set glPolygonOffset(0.0, -3) but it doesn’t work. Compilator doesn’t know a constant called GL_POLYGON_OFFSET, is it a GL extension or what? How I have to fix it?

And what is GL_ALPHA_TEST ?


Hello glYaro,

If enabled, do alpha testing. Also See glAlphaFunc .

I think it’s GL_POLYGON_OFFSET_FILL. But I don’t see why you would need it, unless you are drawing the text as a decal on existing geometry.

Sounds to me like you don’t have alpha channel, or your alpha is one all over the texture. The letters should be in the alpha channel, color channel should be completely white. Then it will work with that blending function.