[SDL] transparency wierdness

Jonathan Dearborn grimfang4 at hotmail.com
Mon Jan 28 13:05:16 PST 2008


Hey,

I think that kind of effect can be fun sometimes.  Being able to 'erase' to reveal previous stuff leads to some neat ideas.  You can do the same thing with my Sprig library.  About the problem, though, the only thing that occurs to me is that your background surface might have the same colorkey as the foreground surfaces.

Jonny D



Date: Mon, 28 Jan 2008 16:24:01 +0000
From: e_byard at yahoo.co.uk
To: sdl at lists.libsdl.org
Subject: [SDL] transparency wierdness



Hi

I have a game where I display a "loading" full-screen-size graphic directly to the screen, then create a buffer for my game components, then when it's ready, blit it all to the screen, thus over-writing the "loading" screen.

In preparing my game screen buffer, I blit the background, followed by various foreground elements, some of which have transparency, some don't.

All fairly simple. ...

Except that any graphics I have which use any amount of alpha (except total transparency) shows up the background of the "loading" screen, and I don't understand why!!

I thought it might be that my game buffer is a different format from my screen buffer (returned from SDL_SetVideoMode) but I can't see that it is. 

My foreground elements are loaded with the
 following code:

#define COLORKEY        255,0,255,0

SDL_Surface* GfxSystem::loadGraphic(char *fileName)
{
    SDL_Surface *tmp;
    SDL_Surface *opt;
    
    tmp = IMG_Load(fileName);

    if (tmp == NULL)
    {
        printf("Can't open file: ", fileName, SDL_GetError(), "\n");
        return tmp;
    }
    else
    {
        if (SDL_SetColorKey(tmp,SDL_SRCCOLORKEY|SDL_RLEACCEL,SDL_MapRGBA(tmp->format,COLORKEY))==-1)
        {
            printf("Colorkey will not be used, reason: \n", SDL_GetError(), "\n");
       
 }        
        opt = SDL_DisplayFormatAlpha(tmp);
        SDL_FreeSurface(tmp);
    }
    return opt;
}

Any help GREATLY appreciated!

Ed


       Sent from Yahoo! - a smarter inbox.
_________________________________________________________________
Need to know the score, the latest news, or you need your Hotmail®-get your "fix".
http://www.msnmobilefix.com/Default.aspx
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20080128/f32d3091/attachment-0001.html 


More information about the SDL mailing list