Fading in/out

Hi,

Can anyone post code that fade in and out, or show me some links of this
please? Thanks. (I have searched through libsdl.org and only found one
article for 16bbps).

thanks in advance
James

An embedded and charset-unspecified text was scrubbed…
Name: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20021125/50a68e79/attachment.asc

Hi,

I wrote something (including source) about it. It uses alphablending with a black surface, and
works for each bit-depth, but is rather slow in hardware (but very fast in software). I have
to modify so that it creates a temorary software surface and blit it to the hardware… If I
find the time :frowning:

You can read it here:

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

Kind regards,

Patrick.

Thanks.

btw, could you explain this difference between “but is rather slow in
hardware” and “(but very fast in software).”

Thanks again
JamesOn Tue, Nov 26, 2002 at 02:58:05AM -0500, patrick at 2dgame-tutorial.com wrote:

James Mills @James_Mills schreef:

Hi,

Can anyone post code that fade in and out, or show me some links of this
please? Thanks. (I have searched through libsdl.org and only found one
article for 16bbps).

thanks in advance
James


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


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

An embedded and charset-unspecified text was scrubbed…
Name: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20021126/24bd576b/attachment.txt

To clarify, I hope I’m not stepping on anyone’s toes here, but if you
have to sample the pixel from video memory, it must be transfered across
from video memory to system memory, manipulated then transfered back.
If you update it in system memory you don’t incur the cost of the
transfer from video memory. However, if your video card can handle
alpha blends, then all the pixels are manipulated in video memory.

This method will only really work if you keep a copy of the screen in
system memory. So you need to design your game or whatever in such a
way that your double buffer is actually in system memory, and every flip
that occurs moves it from system memory to video memory. This is
sometimes rather costly, video to video memory transfers are
substantially quicker then system to video memory transfers, since you
don’t have to transfer all the data across the video bus.

If you don’t mind using palette based 8-bit color, you can always just
fade the palette, this is very quick, but unless you have or are a
rather talented artist the art can sometimes look pretty crappy.

That’s my two cents on the matter,
gotta stop drinking and go to bed,
RobertOn Tue, 2002-11-26 at 03:33, patrick at 2dgame-tutorial.com wrote:

Of course,

alphablending is not accelerated on most video cards, which means that SDL has to pixelate on
surfaces when a blend is set. Accessing a surface at a pixel base level is slow for hardware
surfaces, but fast in system memory (just like accessing an array).

Therefore, it is better to perform pixel operation on a software surface, and than plain copy
it (which is accellerated) to a hardware surface.

Patrick.

James Mills prologic at comcen.com.au schreef:

On Tue, Nov 26, 2002 at 02:58:05AM -0500, patrick at 2dgame-tutorial.com wrote:

Hi,

I wrote something (including source) about it. It uses alphablending with a black surface,
and

works for each bit-depth, but is rather slow in hardware (but very fast in software). I
have

to modify so that it creates a temorary software surface and blit it to the hardware… If I
find the time :frowning:

You can read it here:

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

Kind regards,

Patrick.

Thanks.

btw, could you explain this difference between “but is rather slow in
hardware” and “(but very fast in software).”

Thanks again
James

James Mills prologic at comcen.com.au schreef:

Hi,

Can anyone post code that fade in and out, or show me some links of this
please? Thanks. (I have searched through libsdl.org and only found one
article for 16bbps).

thanks in advance
James


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


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


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


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

Thank you guys. I don’t have much knowledge in this area,
SDL/graphics/etc…

thanks
James

Robert Diel wrote:

To clarify, I hope I’m not stepping on anyone’s toes here, but if you
have to sample the pixel from video memory, it must be transfered
across from video memory to system memory, manipulated then
transfered back. If you update it in system memory you don’t incur
the cost of the transfer from video memory. However, if your video
card can handle alpha blends, then all the pixels are manipulated in
video memory.

This method will only really work if you keep a copy of the screen in
system memory.

Well, not necessarily… the alternative is to just create that copy
once, at the start of the fade. You get a delay for that first transfer
from video->system memory but in many cases that may not be a problem.
Doing this every frame wouldn’t be recommended, though.–
Kylotan
http://pages.eidosnet.co.uk/kylotan

James Mills wrote:

btw, could you explain this difference between “but is rather slow in
hardware” and “(but very fast in software).”

Sam Lantinga just wrote a post in the “SDL sound under Mac OS X and
Linux” thread that explains this issue perfectly. It’s a must-read for
anyone trying to get the best performance out of SDL.–
= Video articles: http://tangentsoft.net/video/