03
Nov
08

Code: OpenGL Bitmap Fonts

Today, we draw your attention to some work-in-progress code that could be of use if you’re interested in using fonts in your OpenGL ES application that aren’t available on the iPhone. It’s called OpenGL ES BitmapFont, intuitively enough, and is simple to use

// loading a font

m_pScoreFont = [BMFont alloc];
[
m_pScoreFont loadFont:@"font.xml"];
[
m_pScoreFont setTexture:[TextureManager loadTexture:@"font_00.png"]];
[
m_pScoreFont setRotation:-90.0f];
[
m_pScoreFont setScaling:0.005f];

// printing some text

[m_pScoreFont print:@"SCORE: 0" posX:0 posY:0.8f];

although apparently there’s a few issues to work out still

Known issues of Version 0.1:

  • color changing not working
  • lower-characters are not getting placed correctly

and getting the texture to load requires the use of the Windows Bitmap Font Generator application from AngelCode.com. Still, hey, it’s a start!


Leave a Reply