Friday, April 9, 2010

Bitmap Fonts

I recently added support for Bitmap fonts to my engine. I used the free tool BMFont to do this ( This tool allows you to select a font (face, size, etc) and it generates a bitmap containing the font glyphs as well as a file describing the texture coordinates and spacing. To integrate this into my engine, I extended my asset tool to read the font description file and write it out in a custom file format. The engine then reads in this file at runtime and uses the info to draw the glyphs.

To draw text, a "Text object" is created by the engine that stores a set of VBOs. A dynamic VBO is used to store the texture coordinates and vertex positions for each glyph in the string and a static VBO to store the indices. When the string for the Text object changes, the position/texcoord VBO contents change to reflect the new glyphs to be drawn.

Here is screenshot:

No comments:

Post a Comment