Texture Text

The txf functions in texfont.c draw text using textures.



The font is loaded as a single texture. Each character is a rectangular region within that texture.

Text is drawn as squares, with texture coordinates that cut out just the region containing the desired character.


See http://www.opengl.org/developers/code/mjktips/TexFont/TexFont.html for more information.



Example: txfText.cpp

TXF Code:

Polygon Offsets



If you attempt to draw text directly on a polygon - i.e. coplanar with the polygon - you are likely to run into the problem of "depth-fighting".






This can be addressed using polygon offsets.

     glEnable(GL_POLYGON_OFFSET_FILL);
     glPolygonOffset(0, -10);

Example: offset.cpp





The web pages http://www.opengl.org/developers/code/features/fontsurvey/ and http://sjbaker.org/steve/omniv/opengl_text.html contain further discussions of OpenGL text-rendering methods.