[SDL] Text output - getting more speed in SDL
Ryan C. Gordon
icculus at icculus.org
Sun Apr 15 02:20:19 PDT 2007
> It looks rather horrifying.
I wouldn't have gone that far.
But I'm curious if keeping an array of memory offsets where a glyph's
pixels exist would actually beat SDL's blitters...the method we're
discussing writes to less memory that a default surface blit, but it
doesn't take advantage of the possibility of blitting between hardware
surfaces, or that pixel formats, alpha blending, and conversions can be
handled without cluttering your application and possibly with
MMX/Altivec/SSE behind the scenes.
Colorkey blitting with RLE encoding might achieve close to the same
speed inside SDL for about the same memory usage, too.
(completed untested) I'd have probably kept a table of SDL_Surfaces, one
glyph per surface, hashed by their codepoint and created/cached as
needed, and just blitted from them as I needed to draw glyphs to a
surface. If I wanted to gamble, I could try for things like colorkey
blits and hardware surfaces.
...but I'd probably just build OpenGL display lists from the vertex data
that Freetype can provide and get hardware-accelerated manipulation of
the glyphs for "blitting" or a million other things, which is going to
smoke any possible approach we take here in terms of performance,
features, and application ease-of-use.
It might be nice to add a function to SDL_ttf to get a vertex buffer
back instead of an SDL_Surface...
--ryan.
More information about the SDL
mailing list