Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm about to pick up computer graphics once again for an university project. For a previous project I used a library called FTGL that didn't leave me quite satisfied as it felt kind of heavy (I tried lots of rendering techniques, text rendering didn't scale very well).

My question is, is there a good and efficient library for this? If not, what would be the way to implement fast but nice looking text? Some intended uses are:

  • Floating object/character labels
  • Dialogues
  • Menus
  • HUD

EDIT: Preferably it could also load fonts

share|improve this question
    
This is a "which technology to use question", and thus should probably be closed. –  Laurent Couvidou Jun 11 '13 at 16:26
add comment

4 Answers 4

up vote 2 down vote accepted

A popular framework is Crazy Eddie's GUI.

But whilst that is appealing, its not unusual to roll your own (and perhaps regret it as the scope increases later ;))

Its normal to have your glyphs on bitmaps and then draw the bitmaps using OpenGL.

Sometimes you show transient text that might only appear for a handful of frames. Just using GL_QUADS+glVertex will be sufficient. But for any large quantity of text or any long duration of visibility its well worth putting the GL_QUADS in a VBO - I've noticed big performance improvements from this.

There is of course the question of generating the actual glyphs that you need. There are programs like bmfont that you can use for that. Or you might need rather more complicated rendering, e.g. freetype on demand. I've been using bmfont with my own renderer quite happily, its very straightforward to deduce.

share|improve this answer
add comment

There are a lot of ways - depending on what you want... Like everywhere else, there isn't something like "the best solution". Which plattform is your target? Which language are you using? What is about text resizing/rotation - is it necessary? Do you need to be able to render TrueTypeFonts? Whats about Multilanguage/Unicode? How do you want to store your text (which encoding etc.)?

I used in the past also FTGL, as well as pure freetype (http://www.freetype.org/ FTGL is based on this), different kind of bitmap fonts, outline fonts... Now I'm mostly addicted to bitmap fonts, but thats only my personal preference. Because I dont want to deal with different charsets, encoding and stuff like that anymore - and licensing for bitmapfonts is also easilier and cheaper than for TrueTypeFonts. And its usable on every plattform that can load images. I use simply an quad in openGL and map a part of my texture on it. The other side is: The font will be only clean resizable at a factor about +/-50%. If you can live with that, I would suggest using a bitmapfont.

If you have also to deal with different encoding/charsets you should find a way to load and use TrueTypeFonts (like with freetype, using another library or with your own implemenation)...

Also have an look at nehes different tutorials on this topic:

http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=13 Bitmap Fonts

http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=14 Outline Fonts

http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=15 Texture Mapped Outline Fonts

http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=17 2D Texture Font

Good luck!

share|improve this answer
    
+1 Thanks for the valuable info on performance, I did know about NeHe's tutorials. I think I did use bitmap fonts... but it didn't scale: about 60 labels floating in a scene above spheres joined by lines, any insight to that? (I was thinking I should have looked for a way to implement a flyweight pattern) –  dukeofgaming Jan 22 '11 at 10:38
add comment

If you want to use bitmap fonts, you can't go far wrong with the Angelcode Bitmap Font Generator: http://www.angelcode.com/products/bmfont/

It converts a truetype font to one or more textures (with nicely packed glyphs), and outputs a little file containing the UVs and spacings (I find that the XML output is particularly easy to work with, and the quality of the spacing data is generally very good, even without true kerning)

share|improve this answer
add comment

I'm using the libraries of Sean Barret to render truetype-glyphs under OpenGL (stb_image, stb_truetype).

The Recast/Detour-project is using these libraries to create an user interface (IMUI)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.