Jump to content
  • Advertisement
Sign in to follow this  
Cornstalks

OpenGL Freetype Font Rendering

This topic is 3791 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

So I've been trying to find a good way to render text in OpenGL, and I've finally come across the Freetype Library. I have gone through their tutorials and finally know how to create the bitmaps necessary for rendering the text. The question is this: what's the best way to render these bitmaps? When I load a font, should I create an array of textures, one for each character in the font, and then call the textures I need to render a string? This would also require me to store the width and height for the letters (not the textures, the letters have smaller widths and heights than the textures because the textures have to be padded to a power of 2). Is there a better way or should I just start coding? I just hesitate about this method because it would require me to generate a whole new set of textures if the font size was different or anything like that, plus I don't know how efficient it is. Thanks!

Share this post


Link to post
Share on other sites
Advertisement
Store all the characters in a single texture and store the x, y, width, height values for each character. Then when rendering a string, bind the texture once and for each character, lookup the correct texture coordinates and render a quad per character.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!