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! Mail - a smarter inbox http://uk.mail.yahoo.com

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 DDate: Mon, 28 Jan 2008 16:24:01 +0000
From: e_byard@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

It can be good but not for something that is meant to look the way I want!

I found the problem, my display surface had an alpha value of 4-million odd…changing it to 0 fixed it :-)> ----- Original Message -----

From: grimfang4@hotmail.com (Jonathan Dearborn)
To: A list for developers using the SDL library. (includes SDL-announce)
Sent: Monday, 28 January, 2008 9:05:16 PM
Subject: Re: [SDL] transparency wierdness

.hmmessage P
{
margin:0px;padding:0px;}
body.hmmessage
{
FONT-SIZE:10pt;FONT-FAMILY:Tahoma;}

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: @Edward_Byard
To: sdl at lists.libsdl.org
Subject: [SDL] transparency wierdness

.ExternalClass DIV
{}

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”. Check it out.

-----Inline Attachment Follows-----


SDL
mailing
list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

  ___________________________________________________________

Support the World Aids Awareness campaign this month with Yahoo! For Good http://uk.promotions.yahoo.com/forgood/