[SDL] Fast alpha blitting

David Olsen jolynsbass at hotmail.com
Fri Sep 16 20:02:48 PDT 2005


----- Original Message ----- 
From: "David Olofson" <david at olofson.net>

> On Friday 16 September 2005 19.40, David Olsen wrote:
> [...]
>> If you're trying to get smooth
>> edges on some sprites, for instance, you'll need to stick with the
>> slower per-pixel,
>
> Well, yes - but antialiazed sprites are generally mostly (as in 90% or
> so) fully transparent and fully opaque pixels. If you enable the RLE
> acceleration, the cost of alpha blending only impacts the pixels that
> actually need blending.

Now, this I did not know. That's really great. I had thought that RLE only
really accelerated on a color-based level. So if I call SDL_SetAlpha(xxxxx)
and include both the Alpha, and RLE flags, that it will accelerate when
possible? Is there any time when it would make it go slower?
I guess I'll try it out on my current project and post the results...

Okay, some quick implementing results in the following difference :
 123 FPS without the RLE technique
 125 FPS with the RLE - a small but definite increase in FPS, however :
because of the way I am using these images(as buttons) and checking whether 
or not the mouse is over the button by checking if they are over a 
transparent pixel or not, when the mouse is over one of these buttons, the 
FPS drops to 110 FPS(whereas without the RLE, it stays around 123 FPS). I 
assume this is because of the decompressing of the info on each frame to see 
whether the mouse is still over an opaque part of the button. (Also, the 
performance hit is less, when I do it over a small button, and more when 
over a large button, which makes sense - there's more to decompress on a 
larger image.)
So, for my money, a non-RLE acccelerated surface "works" faster, even though 
the RLE-accel one blits a little faster... But, it all depends on how you 
use it in your project.
Thanks for the great mailing list everyone! I don't post often, but I learn 
lots from reading everyone's elses posts, and I pipe up once in a while when 
I think I know something, even if I actually don't... anyway, keep up the 
good work!
-Dave







More information about the SDL mailing list