[Expat Games logo]
 

Texture Atlases and Bitmap Fonts

| No Comments | No TrackBacks

Working with textures in OpenGL is a pain, for numerous reasons. Working with textures in OpenGL ES, where you have limited memory and a dearth of useful extensions (where art thou, GL_ARB_texture_non_power_of_two?), even moreso. The biggest pain, IMHO, is the requirement that all textures be powers-of-two, i.e., the width and height of all of the textures you give to OpenGL must be a power of two. 32x32 is good, as is 1024x48 -- but 100x100 is right out.

I'm currently working on a project that involves a large number of small textures. At first, I was content to simply pad each of them out, adding extra space to size each up to the nearest acceptable size -- but I quickly realized that I was wasting a lot of memory doing so, and requiring OpenGL to manage an unnecessarily large number of textures in the process. The solution? Texture atlases.

And thus was born AtlasTool.py, a helpful tool for building texture atlases. And because bitmap fonts (another recurring frustration when working with OpenGL) are essentially texture maps in which each texture is a single character glyph, it was easy to extend the atlas tool into a more specialized version for creating bitmap fonts: FontTool.py. FontTool has some useful bonus features as well, like the ability to output font information as a property list-encoded NSDictionary.

Leave a comment