[SDL] fading to black
patrick at 2dgame-tutorial.com
Tue Nov 19 23:13:00 PST 2002
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:
>On Wed, 20 Nov 2002 04:18:02 0000 "Matt Monson" <madprog at hotmail.com>
>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
>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
>a problem with my hardware. is there some cool, fast way to do fading that
>dont know about, or is alpha blending how its done?
>Add photos to your messages with MSN 8. Get 2 months FREE*.
>SDL mailing list
>SDL at libsdl.org
More information about the SDL