[SDL] color key broken in glSDL?

David Olofson david at olofson.net
Fri Oct 13 03:59:38 PDT 2006


On Friday 13 October 2006 12:27, James Gregory wrote:
> I just spent absolutely ages trying to work out why my color key was
> not working in glSDL, and eventually discovered that when creating
> an SDL color with SDL_MapRGB the alpha component of the color is set
> to 0, whilst when glSDL is checking which pixels match the color key
> it is checking pixels which can have an alpha component of 255.

Why are you using colorkey on RGBA surfaces in the first place? 
AFAICT, you can't run into this problem without doing something 
backwards. When you're using RGB color values with RGBA pixels, 
you're basically comparing apples to pears.

glSDL will generate RGBA surfaces when you (gl)SDL_DisplayFormat() 
colorkeyed surfaces, because that's how it implements colorkeying 
over OpenGL. (This is indeed a side effect that other backends don't 
have, AFAIK. They're almost the other way around; they accelerate 
colorkeying, but not alpha.)

If you mess with the colorkey settings of display format converted 
surfaces, the display formatting is essentially undone, and glSDL 
will have to do on-the-fly conversion for every blit afterwards. When 
doing so, it'll implement the new colorkey settings over the 
proviously RGBA-converted surface by attempting to key it into a new 
RGBA surface.


//David Olofson - Programmer, Composer, Open Source Advocate

.-------  http://olofson.net - Games, SDL examples  -------.
|        http://zeespace.net - 2.5D rendering engine       |
|       http://audiality.org - Music/audio engine          |
|     http://eel.olofson.net - Real time scripting         |
'--  http://www.reologica.se - Rheology instrumentation  --'




More information about the SDL mailing list