[SDL] Text output - getting more speed in SDL

Kein-Hong Man keinhong at gmail.com
Sun Apr 15 01:16:32 PDT 2007


Leon Marrick wrote:
>      The below contains the fastest text-output function I currently know how 
> to write for SDL.  It is faster than any SDL-based code I've been able to find 
> on the Web:  Not only does it run rings about "TTF_Render_Text()", it also 
> leaves pre-rendering to a bitmap in the dust.
> 
>      But that don't mean a thing.  The application I'm using SDL for requires 
> a highly efficient text-output algorithm, which this one isn't.  If you think 
> you know something about code optimization using SDL, I'd be grateful if you 
> had a look.
> 
> http://runegold.org/sangband/files/text_speed.zip

It looks rather horrifying. Saying "run rings about 
TTF_Render_Text()" is over-simplifying a fair bit, since your 
implementation cannot do grayscale glyphs. If someone wants a 
general text output system that can be easily extended to use TTF 
with grayscale, your implementation may need to be rewritten in 
the long term.

Why isn't a glyph cache used? Is there some sort of memory 
restriction? Do you really need the performance? The maximum 
performance you need is what is enough to render a screenful of 
glyphs at monitor refresh rate; anything more would not really 
improve anything, I think.

> Any useful results will be emailed to Sam Lantinga.

I don't see the point of this; such implementation details are the 
application domain, not in the libsdl domain, so why is there a 
need for the above sentence?

-- 
Cheers,
Kein-Hong Man (esq.)
Kuala Lumpur, Malaysia




More information about the SDL mailing list