Forum Thread
font system for OpenGL 2D for commerical projects (Forums : 2D Graphics : font system for OpenGL 2D for commerical projects) Locked
Thread Options
Sep 18 2012 Anchor

Anyone want to point me in the right direction for a free easy to use font system for my OpenGL engine? I also need to make sure it can be used for commercial projects.

Does anyone know if BMP image format is allowed to be used for commercial games?

Sep 18 2012 Anchor

BMP can, yes, but normally TGA is the preferred format.

Not sure about the font system. All id gpl engines have a font system, maybe lift it from there (your code would be GPL though).


Go play some Quake 2:
It's like Source v0.9, only... better!
Play Paintball for Doom 3!:
Doom 3 Paintball to the Max!

Jok3r098 “A computer is like air conditioning – it becomes useless when you open Windows” - Linus Torvals
Sep 18 2012 Anchor

there are open source GUI systems like GWEN which afaik could probably be used in commercial applications.;
but its not overly hard to write your own. something like this:

int textSheetHandle;
void init(){
   textSheetHandle = loadTextSpriteSheet();
void drawLetter(char ch, float x, float y){
   //Work out where on the spritesheet the letter is, for example take the ascii value as the index on the sheet.
   int sheetx, sheety;
   sheety = (int)((int)ch/16); // ascii value / total number of cols.
   sheetx = (int)ch - sheety;
   glTranslatef(x, y, 0.0f);
   glTexCoord2f( sheetx, sheety );                         
   glVertex2f( 0, 0 );

   glTexCoord2f( sheetx+characterWidth, sheety); 
   glVertex2f( characterWidth, 0 );

   glTexCoord2f( characterWidth, characterHeight ); 
   glVertex2f( characterWidth, characterHeight );
   glTexCoord2f( sheetx, characterHeight);         
   glVertex2f( 0, characterHeight);                
void drawString(float x, float y, string instr){
   glBindTexture(GL_TEXTURE_2D, textSheetHandle);
   foreach letter in instr:
        drawLetter(letter, x + (numCharactersSoFar*characterWidth), y);

obviously you might want to do some more complacated stuff like carriage returns, or putting the string into a vertex buffer so its faster to draw next time, etc, but that shouldn't be too difficult to do.

Sep 21 2012 Anchor

this perhaps or

Edited by: vfn4i83

Reply to thread
click to sign in and post

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.