Jump to content
  • Advertisement
Sign in to follow this  
underthesun

OpenGL one texture for whole font vs one texture per char

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

For drawing fonts in opengl/directx, would using one texture for the whole font be faster than having many textures, each representing a different character of the same font? The reason I'm asking this is that my font drawing routine is a bit slow. I'm guessing switching between them textures are taking a bit of time. Would this be a valid guess?

Share this post


Link to post
Share on other sites
Advertisement
Yes. You almost always want to use a single texture with all of the font glpyhs embedded. This lets you draw any amount of text in a single draw call, vs. one draw call per character. Depending on what kind of hardware and drivers you've got, the overhead per draw call can be pretty bad.

Share this post


Link to post
Share on other sites
ya, you should really use a texture atlas for your font instead of individual textures because of the draw call overhead.

~Graham

Share this post


Link to post
Share on other sites
Thanks, on my way to implementing some sort of bitmap font loader now :D Doesn't look complicated but reading the format seems to take some effort..

thanks

Share this post


Link to post
Share on other sites
Interesting, lightmaps.. that seems to be different than the "lightmaps" most usually referred to (which has something to do with lighting?).

With these packed textures, will it ever cause float inaccuracies? As in, since texture coordinates are done using floating point, and when the texture being used is large enough, there will be a point when you won't have accurate textures? Just worried since this is ever more important with fonts.

I managed to find a bitmap text generator that does things for you, and I'm using it now (partly because the iphone also doesn't let you embed any custom fonts, unless you use freetype etc).

Share this post


Link to post
Share on other sites
no floats have plenty of precision to address the pixel centers for the texture sizes. make sure to disable multisampling while rendering stuff like this so the gpu doesn't sample outside the glyph rects on the quad edges.

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!