[SDL] sprites and animation

David Olofson david at olofson.net
Tue Nov 11 22:14:02 PST 2003

On Wednesday 12 November 2003 03.26, John Philip wrote:
> On Nov 11, 2003, at 1:01 AM, Alan Wolfe wrote:
> > Is it better to store multiple pictures per surface when you have
> > alot of em
> > or one picture per surface?
> I would like to ask this question about tilesets. Is it the same
> answer as for spritesets?

Not quite, since tiles are often opaque, which means that RLE doesn't 
provide a performance gain. That is, you might as well blit rects 
from a big surface (clipping), even when using software rendering.

(Tiles for multilayered maps and the like, with transparency count as 
sprites in this regard, of course.)

> On Nov 11, 2003, at 7:06 AM, David Olofson wrote:
> > Also note that if you're using RLE acceleration (which is
> > strongly recommended if you have colorkey or alpha channels),
> > there is an additional cost to clipping which is avoided if you
> > use one surface per sprite.
> >
> > ...so you should pretty much always ask for
> > RLE acceleration if you have alpha channels.
> I recently conducted some frame rate comparison in my application,
> which repeatedly blits a 36x17 tile out of a 576x272 surface to
> tile the screen. (Each 36x17 tile in the surface has a diamond of
> colored pixels in it, and four transparent corners) My conclusion
> was that it actually took LONGER to tile the screen with RLE
> enabled on the surface. Is this because of the clipping overhead
> you mentioned?

Yes. Haven't studied the SDL implementation carefully, but RLE 
blitters in general have to skip horizontal spans to find the spans 
to blit for each pixel row. Unless there's a "row look-up table" or 
similar extra data, it even has to scan all spans, row by row, until 
it finds the row the sprite starts on, though I wouldn't think the 
SDL blitter does that.

//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