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