[SDL] fading to black

patrick patrick at 2dgame-tutorial.com
Tue Nov 19 23:13:00 PST 2002


Hi,

you're right, alphablending is easiest, but very slow in hardware. I wrote a
util for it, I only have still to modify it that it creates a software
surface and then do a regular blit to the hardware surface.

This is the trick in case of hardware surface:

1. Create temporary surface in SOFTware
2. Copy the hardware surface to it with a regular blit
3. Blend the black surface (also surface) over it
4. Blit the temporary surface back to the hardware surface

My utility is synchronous, which means in this case that entire fade is
done, before exiting the function. Therefore, the overhead of only once
creating and destroying the temporary surface is very low.

You can read it here:

http://www.2dgame-tutorial.com/sdl/fading.htm

Patrick.

>On Wed, 20 Nov 2002 04:18:02  0000 "Matt Monson" <madprog at hotmail.com>
wrote.
>i've always thought it looks cool when menus, etc fade to black and then 
>back in when changing and stuff.  is this done with alpha blending or 
>something else? i know you could use pallete tricks, but i'm doing 16bit
and 
>dont want to get away from that. alpha blending seems to be really slow on 
>my computer in 2d. in 3d it seems to be really fast, but apparently its not

>done in hardware in 2d. btw, my system is AMD XP 1700 , gf3ti200, so its
not 
>a problem with my hardware. is there some cool, fast way to do fading that
i 
>dont know about, or is alpha blending how its done?
>
>_________________________________________________________________
>Add photos to your messages with MSN 8. Get 2 months FREE*. 
>http://join.msn.com/?page=features/featuredemail
>
>
>_______________________________________________
>SDL mailing list
>SDL at libsdl.org
>http://www.libsdl.org/mailman/listinfo/sdl





More information about the SDL mailing list