[SDL] What is wrong with SDL_TTF?

David Olofson david at olofson.net
Tue Sep 13 13:12:14 PDT 2005

On Tuesday 13 September 2005 19.38, Jesse Meyer wrote:
> On Tue, 13 Sep 2005, Ricardo Cruz wrote:
> >  In my opinion, instead of converting TTF fonts to bitmaps in
> >  run-time you should do so before to avoid extra dependecy, make
> >  the engine simpler and use of less cpu and memory.  Making a
> >  program to convert TTF to a bitmap is very simple, as well as
> >  making it accept arguments and add graphical effects.
> > 
> > Cheers, 
> > Ricardo
> Perhaps its my laptop hardware (PII, 300mhz no hardware accel
> support), but I've found that blitting bitmap fonts for each frame
> still gives me a noticeable slowdown.
> I ended up storing a copy of the text in memory, and blit to the the
> main display only when that part of the screen needs to be redrawn.
> Much more friendly for the CPU at the cost of a little memory.

Well, of course, you can never eliminate the cost of the blit to the 
screen, unless you simply don't do it! :-)

However, if you have a lot of stuff moving around and/or a scrolling 
background, there's no way to avoid redrawing the text every frame - 
and that's when it matters how you do it.

(And the fastest way to do it is probably prerendering the whole 
message into a surface, DisplayFormat() it, with RLE acceleration 
where appropriate, and then just do a single blit per update. This 
will not work if you need to generate new messages while the time 
critical main loop is running, though. Well, you *can* do that too, 
but that's a bit more complicated...)

//David Olofson - Programmer, Composer, Open Source Advocate

.- Audiality -----------------------------------------------.
|  Free/Open Source audio engine for games and multimedia.  |
| MIDI, modular synthesis, real time effects, scripting,... |
`-----------------------------------> http://audiality.org -'
   --- http://olofson.net --- http://www.reologica.se ---

More information about the SDL mailing list