PDA

View Full Version : State of the text drawing solutions



HermanHermits
12-30-2010, 07:34 AM
I'm trying to find the best way to display text in my OpenGL program. My objectives are:

- Solution should be cross platform: Mac OS, Windows, Linux.
- Standard system font types should be supported - no proprietary formats.
- Small text size should draw clearly (without anti-aliasing).
- 2D text is a must, 3D is nice but not required.

I know the OpenGL is a hardware abstraction layer and does not support text drawing directly. I also know that almost all OpenGL programs do need to display some text, and I would expect some good standard solution to emerge. Looking at font survey (http://www.opengl.org/resources/features/fontsurvey/) font survey reveals that the situation is very lame. Most libraries mentioned are not in active development, some URLs are broken. I checked each library on the list - here is what I discovered:

GLX: Unix only
GLC: SGI only
GLUT: very limited font support, no mention of Mac support, last updated 1998 (?)
Texture Mapped Text: several solution mentioned here, broken URLs. glFont last updated 2005 does not seem like an actively developed library. FTN is TXF specific.
GLTT: Last updated 2001. Mailing list full of spam. Does not seem like an actively developed library.
WGL: Windows only.
GLF: Uses proprietary font format, URL broken.
FTGL: This looks like the only actively developed cross platform working solution. Mailing list active but many posts remain unanswered. Requires FreeType2.

So I'm currently evaluating FTGL, but would like to learn from other people experience before committing. Rolling my own solution using native OS API is also possible.

Thanks for any advice,

Herman

Alfonse Reinheart
12-30-2010, 10:44 AM
- Small text size should draw clearly (without anti-aliasing).

Small text looks pretty bad without antialiasing. Not unless you create specific glyph bitmaps for specific small text sizes, and that's usually not done by most standard font formats.


I also know that almost all OpenGL programs do need to display some text, and I would expect some good standard solution to emerge.

Well, most people tend to roll their own, using FreeType or some other glyph drawing system to render the glyphs to a bitmap, which then gets uploaded into a texture or whatever and rendered as needed. This isn't particularly difficult code (for simplistic cases of course. Full Unicode layout isn't so simple, and none of the public libraries have that), so it isn't something that people use often enough to matter. And to be honest, the layout code is the hardest part; simply rendering a glyph is not exactly demanding. It's getting the right glyphs in the right order that's tricky.