It turns out both the software and the OpenGL renderer had the same problem.
authorSam Lantinga <slouken@libsdl.org>
Tue, 25 Nov 2008 05:29:14 +0000
changeset 278793764fe8601a
parent 2786 6bacfecbf27e
child 2788 44be910366a9
It turns out both the software and the OpenGL renderer had the same problem.
According to the spec, when SDL_SRCALPHA is set, the colorkey is ignored, so
we just need to convert the colorkey into the alpha channel.
src/video/SDL_surface.c
src/video/SDL_video.c
     1.1 --- a/src/video/SDL_surface.c	Tue Nov 25 02:21:53 2008 +0000
     1.2 +++ b/src/video/SDL_surface.c	Tue Nov 25 05:29:14 2008 +0000
     1.3 @@ -270,7 +270,7 @@
     1.4  }
     1.5  
     1.6  /* This is a fairly slow function to switch from colorkey to alpha */
     1.7 -void
     1.8 +static void
     1.9  SDL_ConvertColorkeyToAlpha(SDL_Surface * surface)
    1.10  {
    1.11      int x, y;
    1.12 @@ -813,6 +813,7 @@
    1.13                      &keyG, &keyB, &keyA);
    1.14          SDL_SetColorKey(convert, 1,
    1.15                          SDL_MapRGBA(convert->format, keyR, keyG, keyB, keyA));
    1.16 +        SDL_ConvertColorkeyToAlpha(convert);
    1.17      }
    1.18      convert->map->info.r = surface->map->info.r;
    1.19      convert->map->info.g = surface->map->info.g;
     2.1 --- a/src/video/SDL_video.c	Tue Nov 25 02:21:53 2008 +0000
     2.2 +++ b/src/video/SDL_video.c	Tue Nov 25 05:29:14 2008 +0000
     2.3 @@ -46,9 +46,6 @@
     2.4  #endif
     2.5  #endif /* SDL_VIDEO_OPENGL */
     2.6  
     2.7 -/* From SDL_surface.c */
     2.8 -extern void SDL_ConvertColorkeyToAlpha(SDL_Surface * surface);
     2.9 -
    2.10  /* Available video drivers */
    2.11  static VideoBootStrap *bootstrap[] = {
    2.12  #if SDL_VIDEO_DRIVER_COCOA
    2.13 @@ -1588,7 +1585,6 @@
    2.14              }
    2.15              dst = SDL_ConvertSurface(surface, dst_fmt, 0);
    2.16              if (dst) {
    2.17 -                SDL_ConvertColorkeyToAlpha(dst);
    2.18                  SDL_UpdateTexture(textureID, NULL, dst->pixels, dst->pitch);
    2.19                  SDL_FreeSurface(dst);
    2.20              }