Fade screen

hi,
What is the easiest way to fade the screen?
I tried to paint a semi-transparent black rectangle like this:

static void paintFade() {
static SDL_Rect paintRect;
static Uint32 fade=SDL_MapRGBA(screen->format,0,0,0,128);

paintRect.x=0;
paintRect.y=0;
paintRect.w=screen->w;
paintRect.h=screen->h;

SDL_FillRect(screen, &paintRect, fade);
}

But it didn’t work. maybe because screen->format does not include an
alpha channel?
/ Daniel U

Hello

I have done this in my game. Maybe the code will be helpful for you.
You can find it at:
http://cvs.sourceforge.net/viewcvs.py/wheep/wheep/wheep.c

Have a look at the FadeScreen() function. I’m sure it could be done
better, but it works.

Have a nice day,
Bernhard

Daniel Uppstr?m wrote:> hi,

What is the easiest way to fade the screen?
I tried to paint a semi-transparent black rectangle like this:

static void paintFade() {
static SDL_Rect paintRect;
static Uint32 fade=SDL_MapRGBA(screen->format,0,0,0,128);

paintRect.x=0;
paintRect.y=0;
paintRect.w=screen->w;
paintRect.h=screen->h;

SDL_FillRect(screen, &paintRect, fade);
}

But it didn’t work. maybe because screen->format does not include an
alpha channel?
/ Daniel U


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

The files in ‘images’ won’t download.

JPOn Friday 06 February 2004 03:18 pm, Bernhard wrote:

Hello

I have done this in my game. Maybe the code will be helpful for you.
You can find it at:
http://cvs.sourceforge.net/viewcvs.py/wheep/wheep/wheep.c