Friday, January 27, 2017

textures - Preferred way to render text in OpenGL



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



Answer



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.


No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...