Sprites and animation

Hey guys,

Is it better to store multiple pictures per surface when you have alot of em
or one picture per surface?

I’m talking about sprites (with multiple frames of animation) so they are
like 32x64 on average.

Thanks!

The advantage to storing images in their own surface is that
a) you don’t have to calculate any rect coordinates for blitting
b) you can alter the surface and not have it affect the remaining frames

The disadvantage is that you use more memory for the descriptor portion of
the surface.> ----- Original Message -----

From: atrix2@cox.net (atrix2)
To:
Sent: Monday, November 10, 2003 10:01 PM
Subject: [SDL] sprites and animation

Hey guys,

Is it better to store multiple pictures per surface when you have alot of
em
or one picture per surface?

I’m talking about sprites (with multiple frames of animation) so they are
like 32x64 on average.

Thanks!


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

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.

Of course, RLE is used only for software rendering, so if you’re on a
h/w accelerated rendering target, this clipping overhead is
eliminated anyway. Note that very few targets accelerate alpha (only
DirectFB and glSDL, AFAIK), so you should pretty much always ask for
RLE acceleration if you have alpha channels.

//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.nethttp://www.reologica.se —On Tuesday 11 November 2003 11.02, hah coe wrote:

The advantage to storing images in their own surface is that
a) you don’t have to calculate any rect coordinates for blitting
b) you can alter the surface and not have it affect the remaining
frames

The disadvantage is that you use more memory for the descriptor
portion of the surface.

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?On Nov 11, 2003, at 1:01 AM, Alan Wolfe wrote:

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?

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 Wednesday 12 November 2003 03.26, John Philip wrote:

On Nov 11, 2003, at 1:01 AM, Alan Wolfe wrote:

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.nethttp://www.reologica.se

Alan Wolfe wrote:

Is it better to store multiple pictures per surface when you have
alot of em or one picture per surface?

Definitely one picture per surface.–
Rainer Deyke - rainerd at eldwood.com - http://eldwood.com

John Philip 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?

Assuming a picture size of 8x8 or greater, one picture per surface is always
better when you have any kind of transparency (colorkey or alpha channel),
and in no case significantly worse than multiple pictures per surface.> On Nov 11, 2003, at 1:01 AM, Alan Wolfe wrote:

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.


Rainer Deyke - rainerd at eldwood.com - http://eldwood.com