Short and simple: I create a 32 bit surface with alpha - channel (R8G8B8A8), and colorkeys stop working.
#include <SDL/SDL.h>
#include <iostream>
using namespace std;
int main(int argc, char **argv)
{
SDL_Init(SDL_INIT_EVERYTHING);
SDL_SetVideoMode(800, 480, 16, SDL_SWSURFACE);
SDL_BlitSurface does not support simultaneous alpha channel and colour keying. One solution is to modify the colour keyed pixels to have a transparent alpha value.
if (source surface has SDL_SRCALPHA set) {
if (source surface has alpha channel (that is, format->Amask != 0))
blit using per-pixel alpha, ignoring any colour key
else {
if (source surface has SDL_SRCCOLORKEY set)
blit using the colour key AND the per-surface alpha value
else
blit using the per-surface alpha value
}
} else {
if (source surface has SDL_SRCCOLORKEY set)
blit using the colour key
else
ordinary opaque rectangular blit
}
I haven't set SDL_SRCALPHA(or is it set automaticly?), so following that code I should end with "blit using the colour key", shouldn't I?