VSFontLib – Very Simple Font Library
With immediate mode gone in core OpenGL versions, so are the vast majority of font libs that worked with OpenGL. Immediate mode was terribly slow, and code wise very extensive. Vertex Buffers are clearly the way to go.
Text rendering is very useful to display information on top of a 3D world. Since I couldn’t find a solution for this problem I implemented a simple one to render bitmapped text. If there are other public libs available out there to add to our applications to perform this task, please let me know and I’ll add a link to them here.
I just needed an application that produced a texture with the characters and a file with the texture coordinates to access each individual character.
I found a solution with an “old” application called FontStudio by Michael Pote. The site (www.nitrogen.za.org) no longer exists but I was able to find a copy on the Classic Web Archive (be patient, it takes a while to load but it will get there).
FontStudio is fairly complete and provides a lot of options for character placement and text effects. It also produces an image with all the chars (and an alpha channel) as well as a XML file with the needed texture coordinates.
The VSFontLib loads these files, image (TGA) and xml, to load the font data. With VSMathLib you can load as many fonts as you want simultaneously.
After these files are processed, VSFontLib is ready to render strings. To make life easier for the programmer, VSFontLib takes care of every detail, from setting the correct perspective so that the fonts are properly drawn on the screen, building VAOs to store the triangles for each char of the sentence, and restore your old settings for the modelview and projection matrices. To handle the matrices, VSFontLib , uses another Very Simple Lib, VSMathLib.
VSFontLib also does full memory and resource (Vertex Array and Buffers) management so you don’t have to worry about it.
- Initial release
- VSMathLib to handle matrices
- GLEW to access OpenGL new functionality
- DevIL to load the TGA image with the drawn chars
- TinyXML to load the XML file with the texture coordinates.
To download go to VSL Downloads page.