glyph.[ch]

This module provides an efficient, portable means of rendering text using OPENGL. It renders text as polygons, since polygonal text scales both up and down better than texture-mapped, line-stroke, or bitmap text.

Each glyph is represented using only a few triangles, specified using triangle strips. In most cases, each vertex is touched only once.

This code is self-contained and does not rely upon GLX, WGL, Freetype, or any other external library. It can be easily included in code for any platform. It has been tested under Windows, Linux, OS X, and even IRIX. The font description requires less than 2KB of memory and is specified in less than 500 lines of C code. It is linked directly with the application, so no external file loading is necessary. The module has exactly one API entry point.

void draw_glyph(int c)

Draw the glyph for ASCII character c. Glyphs are drawn mono-spaced in a 1x1 unit square in the Z plane. This geometry may be transformed normally. In the opinion of the author, it looks best when scaled to a 1:2 aspect ratio.

A translation one unit to the right is applied after each glyph is drawn. This allows a string to be rendered as a sequence of calls to draw_glyph.

Text is rendered using the current material properties. If the text is to be lit, set the current normal to [0 0 1] before calling the renderer. draw_glyph uses OPENGL immediate mode, but it may be called during the creation of a display list. Only slightly more effort is required to create vertex arrays. Representations of all 128 ASCII characters are defined. Non-printing characters appear as a "no glyph" box.

kooima@csc.lsu.edu