'struct SDL_PixelFormat' has no member named 'alpha'

Hi,

I was just trying to port an SDL 1.2 game to SDL 1.3. Most code just compiled without any change. The only error I am getting a few times here and there is:

Code:
error: ‘struct SDL_PixelFormat’ has no member named ‘alpha’

What is the naive/simple way to fix this?

Also, we need to keep the code SDL 1.2 compatible for now, so how do I fix it in a way that the code compiles on both SDL 1.2 and SDL 1.3?

Thanks,
Albert

Ok, I have wrapped it now with:

Code:
inline Uint8 getPerSurfaceAlpha(SDL_Surface* surf) {
#if SDL_MAJOR_VERSION == 1 && SDL_MINOR_VERSION <= 2
return surf->format->alpha;
#else // SDL >=1.3
Uint8 alpha = 0;
SDL_GetSurfaceAlphaMod(surf, &alpha);
return alpha;
#endif
}

Not the nicest way, also it doesn’t do any checks, it just is intended to replace surf->format->alpha by getPerSurfaceAlpha(surf).