[SDL] need a few sugestions from you

skinncode skinncode at centras.lt
Wed Aug 8 05:28:00 PDT 2001


mornin' guys,

i have the following procedure that fades out the current screen to the color given.

void fade_out(Uint32 color) {
        SDL_Surface *s;
        short int e;
        s = SDL_CreateRGBSurface(SDL_SWSURFACE, SCREEN->w, SCREEN->h,
                                 SCREEN->format->BitsPerPixel,
                                 SCREEN->format->Rmask,
                                 SCREEN->format->Gmask,
                                 SCREEN->format->Bmask,
                                 SCREEN->format->Amask);
        SDL_BlitSurface(SCREEN, NULL, s, NULL);

       for(e = 255; e > 0; e -= 10) {
                SDL_FillRect(SCREEN, NULL, color);
                SDL_SetAlpha(s, SDL_SRCALPHA|SDL_RLEACCEL, e);
                SDL_BlitSurface(s, NULL, SCREEN, NULL);
                SDL_Flip(SCREEN);
        }
        SDL_FreeSurface(s);
}

it works fine, though a bit slow on higher resolutions. so i ask you if you could gimme a few sugestions on how to improve this code to make it
faster or anything else that goes into your geek-minds.
thanks a lot,
c ya,
--skinncode





More information about the SDL mailing list