Jump to content
  • Advertisement
Sign in to follow this  
Almindor

OpenGL OpenGL TTF blits

This topic is 3657 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!