OpenGL TTF blits

Started by
0 comments, last by JL4453 15 years, 10 months ago
I'm currently using SDL_ttf in combination with OpenGL to blit text with ttf font. Currently I simply blit it on a software surface via TTF and then load that surface to GL as texture and output that. For now it's enough because I only blit text in menu etc. when the speed really doesn't matter much, but I'd like to know of a better method. Is there a library or such which can output ttf/text directly via openGL?
Advertisement
I've had moderate success implementing a FreeType font class as is done in the NeHe tutorial (google "nehe tutorial 43"). Described there is a method which loads a .TTF font file and constructs texture mapped quads for each letter, and stores them in precompiled display lists on the GRAM which can be called using "glCallLists". A print method is given which takes a string as input and calls the appropriate letter display lists one by one to draw the string, & information is readily accessible as to the width of each letter etc. The text can be rotated, scaled, or translated same as any openGL primitive. I'm not sure exactly how fast this is compared to the method you say you are using but I get the impression that it is about the fastest way to draw text dynamically on screen given the presence of 3D acceleration hardware. My framerates only start to dip when I start drawing many thousands of characters on screen at once.

I gather that it may be possible to use FBOs (framebuffer objects) to get even faster, essentially drawing the text to a faux-framebuffer and storing that as a texture which can be drawn as-is over and over until the text needs changing (i.e. until someone types another letter). But I've been told and agree that this may be excessive for small scale text operations.

This topic is closed to new replies.

Advertisement