Sign in to follow this  

A font performance question

This topic is 3493 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 would like to apologize if this has been posted before (I couldn't find an exact answer to my question using search), but I am very new to this. I am trying to create a class to handle all of my font data and drawing methods. In the constructor, I create a display list for each of the individual characters I plan on using. Later, the drawChar method calls the respective display list for the necessary character. The raster format is luminance alpha, so 16 bits per pixel. My problem is this: is it faster to use glDrawPixels for each letter or to create a texture for each and map it to a quad for each letter? When a display list is made with glDrawPixels, is the pixel data stored in RAM or VRAM? If the texture method is faster, can anybody explain why it is faster? I'm guessing that it has to do with where the image data is stored.

Share this post


Link to post
Share on other sites
From what I understand, these are best (in decreasing preference):

- Render text to 1 texture, reuse texture as needed.
- Render common words to 1 common texture, reuse as needed; combine as needed.
- Render common words to 1 texture per, reuse/combine as needed.
- Render chars to texture, combine as needed.
- DrawPixel sort of scheme.

Cards are hyper-optimized to deal with textures, and switching texture contexts will be your major hot-spot. But as usual, YMMV depending on usage pattern and other requirements. And I of course might be off base/out-dated in my remembering.

[edit: also, per-character rendering will have issues with most modern TrueType fonts since their characters are variable width depending on their context]

Share this post


Link to post
Share on other sites
Thank you for the quick response!

Quote:
- Render text to 1 texture, reuse texture as needed.


How would you go about doing this? Would you create a single texture with all of the characters in a line, then map a certain part of this single texture to a quad?

Quote:
[edit: also, per-character rendering will have issues with most modern TrueType fonts since their characters are variable width depending on their context]


Sadly, I figured this out the hard way. Perhaps if what I said above was correct, I could create an integer array with the x position and width of each character so that I can map it correctly.

EDIT: Nevermind, I figured it out! Thank you so much for the help!

Share this post


Link to post
Share on other sites
I would go with Telastyn's first suggestion. Basically you create a texture that holds ever character. Then you also have an array or map or something that stores the coordinates for each character in the texture. Then when you want to render the work "bike" you look up the coordinates in the texture where "b" is located, render it to a single quad, then look up the coordinates in the texture for the letter "i", render it to a quad, then for k, then for e.

Share this post


Link to post
Share on other sites
Is using a graphical (texture) font better than using Bitmap fonts? surely changing the font in the case of bitmap fonts has to use less memory etc.. than using a texture for each letter?

Share this post


Link to post
Share on other sites

This topic is 3493 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this