Fast font rendering with per-character transformations - Printable Version
+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Graphics & Audio Programming (/forum-9.html)
+--- Thread: Fast font rendering with per-character transformations (/thread-743.html)
Fast font rendering with per-character transformations - moridinbg - Sep 18, 2009 06:22 AM
I am looking for a way to render lots of text with many per-character transformations. For example a sentence in the form of a spinning circle, or a sentence floating around, following a Bezier curve.
I have tried with FTGL which has rather unpleasant API and doesn't work correctly with glOrtho.
Then I tried with QuesoGLC, which has really nice API, following the GLC specification and integrates seamlessly with OpenGL. Unfortunately I had awful performance hit when I tried to render several sentences, character by character.
GLFT seems like a great library for my goals, as it provides per-character transformation with display lists, when rendering entire strings of text. Unfortunately, although I compile the library correctly (with FreeType) I couldn't run the examples, because it states that it cannot create the font faces with the fonts I provide (arial.ttf, courier new.ttf, some unknown Type1 font).
Here is a video of what I want to achieve (implemented with QuesoGLC): http://www.youtube.com/watch?v=yM72XCqnb_c
Fast font rendering with per-character transformations - AnotherJake - Sep 18, 2009 08:52 AM
I don't know anything about QuesoGLC or GLFT, but I tried FTGL years ago and didn't like the API either.
If you aren't changing the layout of the letters on the fly (like how your circles of text in the video don't change, except to rotate), then the most efficient way to do it is to render the text to a single texture. FreeType might be the best way to go, although you might be able to use Quartz more easily instead if you don't mind staying Mac-only. With FreeType, you'll have to transform the pixels yourself for each glyph and software-render them into your texture. That's how you'd use FreeType anyway, but you'd have the additional step of adding a 2D transform.
If you need to change the layout of the letters on the fly (e.g. animated waving text), then you'll probably have to take the old bitmap font approach of putting each character on a separate quad, so it can be transformed separately on the fly. This approach will logically be less efficient than a single quad for each sentence and hence may exhibit performance problems when rendering lots of characters, but is usually fine up to a point.
Fast font rendering with per-character transformations - Skorche - Sep 18, 2009 11:06 AM
I dunno, I've ben able to render hundreds of characters per frame using the bitmapped font approach without a noticeable speed hit. I've never really tried to figure out what the upper limit is, but it seems pretty high.
As long as your character transformations are simple matrix transforms, I can't really seeing it as being a big hit either. You already need to do a translation per character anyway.
Fast font rendering with per-character transformations - AnotherJake - Sep 18, 2009 03:00 PM
Ya, hundreds of bitmap-on-quad characters on modern hardware, no problemo. I remember back in the day, on the Rage128 being significantly affected when into the hundreds and trying to render other geometry at the same time though (of course we aren't dealing with Rage128's anymore -- maybe iPhone, but that can only display so much text at once at a time anyway because of the screen size). I guess it depends on what you're doing, but I'd guess the bitmap font approach should work just fine. It's definitely a lot easier than dealing with FreeType.
Fast font rendering with per-character transformations - Fenris - Sep 19, 2009 01:01 AM
I'm still working on a lightning-fast font library that should be able to do just about this. It's pretty much finished and it would be awesome to have a use-case to tune it to. PM me if you'd like a Î² build.
Fast font rendering with per-character transformations - moridinbg - Oct 22, 2009 12:56 PM
Update on the situation. I made it work with FTGL. Using FTGLPolygonFont I can render hundred rotating short sentences without unbearable performance hits.
The only thing to notice is that I had to use a monospaced font to be able to correctly wrap a sentence in a perfect circle.
The downside is that I have to render a character, glRotated, another character, glRotated, etc...
It would have been really nice if there was an option to provide per-character/per-word/etc transformation options, like GLFT.
As for the Î², I would be glad to try it out.