SDL 1.2 to SDL2 SDL_SRCCOLORKEY & SDL_SRCALPHA


#1

The flags :

SDL2 SDL_SRCCOLORKEY & SDL_SRCALPHA

have disappeared from the surface->flags so how do I test if a surface has this support?


#2

You can use SDL_GetColorKey to see if you have a color key set, or
SDL_ISPIXELFORMAT_ALPHA to see if your pixel format has an alpha channel.


#3

Thanks found SDL_GetColorKey! Perfect!

Can I also use SDL_GetSurfaceAlphaMod to determine the SDL_SRCALPHA?


Migration Guide lacks SDL1 flags
#4

I could be wrong, but I think it is similar to what SDL_SetAlpha used to be. I’ve only used SDL2, but the wording of the documentation for 1.2 seems to imply that they’re similar.


#5

To clarify. So because of that you feel SDL_ISPIXELFORMAT_ALPHA is a better fit?

Has this got something to do with the blend mode and if so maybe SDL_BlendMode???


#6

No, sorry about that. SDL_ISPIXELFORMAT_ALPHA's recommendation was honestly me misinterpreting the question now that I look at it again. That’s used to tell if the format you’re using has an alpha channel or not. I thought SDL_SRCALPHA was a flag to enable alpha channels. I’m kinda leaning towards SDL_BlendMode being what you want, and you’ll need to set it with: SDL_SetRenderDrawBlendMode.