Fading screen in SDL

Started by
2 comments, last by Rob Loach 18 years, 8 months ago
How do you fade a screen in SDL ??? I am doing an intro pic that has to fade before the main menu :-) isent there a function for this in SDL ? since many games use fading I think it would be rather strange...
Advertisement
You can adjust the alpha properties of a surface with SDL_SetAlpha, slowly decreasing the alpha value to zero (as in a loop) will cause the image to fade out.
If you want to fade the whole screen to a solid color, you can hack it by just rendering a rect over the whole of the screen surface, and gradually changing the rect's alpha so that it becomes more opaque. This is the only method I've ever worked out, and its pretty slow with SDL. You can also do a motion blur with this method.

If you're looking to fade from one screen to another (directly) its going to be a nightmare.

EDIT: Okay, Rob, it isn't a nightmare persay using two screen surfaces (just modulate an alpha value on one and blit it onto the other), but performance wise that'll be a strain. Granted, I dev on a (relatively) low-end system, so "strain" to me might not mean all that much to everyone else [wink]

[Edited by - Mushu on August 3, 2005 9:47:15 PM]
Quote:Original post by Mushu
If you're looking to fade from one screen to another (directly) its going to be a nightmare.
Not necessarily, you'd just have two different screen surfaces that you'd be rendering on while slowly decreasing the alpha of one screen surface while increasing the alpha of the second one. SDL_gfx's rectangleRGBA will help you draw a rectangle with an alpha channel. It's actually not that slow of a process if you hack your way through [smile].
Rob Loach [Website] [Projects] [Contact]

This topic is closed to new replies.

Advertisement