Skip to content

Commit

Permalink
Implemented SDL_SetColorKey.
Browse files Browse the repository at this point in the history
Now testsprite renders perfectly!
  • Loading branch information
icculus committed Feb 19, 2019
1 parent 38391fa commit c0a5429
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/SDL12_compat.c
Expand Up @@ -2226,6 +2226,17 @@ SDL_GetAppState(void)
return state12;
}

DECLSPEC int SDLCALL
SDL_SetColorKey(SDL12_Surface *surface12, Uint32 flag12, Uint32 key)
{
const SDL_bool addkey = (flag12 & SDL12_SRCCOLORKEY) ? SDL_TRUE : SDL_FALSE;
const int retval = SDL20_SetColorKey(surface12->surface20, addkey, key);
if (SDL20_GetColorKey(surface12->surface20, &surface12->format->colorkey) < 0) {
surface12->format->colorkey = 0;
}
return retval;
}

DECLSPEC int SDLCALL
SDL_SetPalette(SDL12_Surface *surface12, int flags, const SDL_Color *colors,
int firstcolor, int ncolors)
Expand Down
2 changes: 2 additions & 0 deletions src/SDL20_include_wrapper.h
Expand Up @@ -86,6 +86,7 @@
#define SDL_UpperBlit IGNORE_THIS_VERSION_OF_SDL_UpperBlit
#define SDL_LowerBlit IGNORE_THIS_VERSION_OF_SDL_LowerBlit
#define SDL_ConvertSurface IGNORE_THIS_VERSION_OF_SDL_ConvertSurface
#define SDL_SetColorKey IGNORE_THIS_VERSION_OF_SDL_SetColorKey

#define BUILD_SDL 1
#include "SDL.h"
Expand Down Expand Up @@ -149,6 +150,7 @@
#undef SDL_UpperBlit
#undef SDL_LowerBlit
#undef SDL_ConvertSurface
#undef SDL_SetColorKey

#ifdef SDL_BlitSurface
#undef SDL_BlitSurface
Expand Down
2 changes: 2 additions & 0 deletions src/SDL20_syms.h
Expand Up @@ -90,6 +90,8 @@ SDL20_SYM(SDL_Surface *,CreateRGBSurfaceWithFormat,(Uint32 a, int b, int c, int
SDL20_SYM(SDL_Surface *,ConvertSurface,(SDL_Surface *a, const SDL_PixelFormat *b, Uint32 c),(a,b,c),return)
SDL20_SYM(int,UpperBlit,(SDL_Surface *a,const SDL_Rect *b,SDL_Surface *c, SDL_Rect *d),(a,b,c,d),return)
SDL20_SYM(int,LowerBlit,(SDL_Surface *a,const SDL_Rect *b,SDL_Surface *c, SDL_Rect *d),(a,b,c,d),return)
SDL20_SYM(int,SetColorKey,(SDL_Surface *a, int b, Uint32 c),(a,b,c),return)
SDL20_SYM(int,GetColorKey,(SDL_Surface *a, Uint32 *b),(a,b),return)
SDL20_SYM(void,FreeSurface,(SDL_Surface *a),(a),)
SDL20_SYM(SDL_Surface*,LoadBMP_RW,(SDL_RWops *a, int b),(a,b),return)
SDL20_SYM(int,SaveBMP_RW,(SDL_Surface *a, SDL_RWops *b, int c),(a,b,c),return)
Expand Down

0 comments on commit c0a5429

Please sign in to comment.