Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
It turns out both the software and the OpenGL renderer had the same p…
Browse files Browse the repository at this point in the history
…roblem.

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.
  • Loading branch information
slouken committed Nov 25, 2008
1 parent 8e54202 commit 335c01a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/video/SDL_surface.c
Expand Up @@ -270,7 +270,7 @@ SDL_SetColorKey(SDL_Surface * surface, Uint32 flag, Uint32 key)
}

/* This is a fairly slow function to switch from colorkey to alpha */
void
static void
SDL_ConvertColorkeyToAlpha(SDL_Surface * surface)
{
int x, y;
Expand Down Expand Up @@ -813,6 +813,7 @@ SDL_ConvertSurface(SDL_Surface * surface,
&keyG, &keyB, &keyA);
SDL_SetColorKey(convert, 1,
SDL_MapRGBA(convert->format, keyR, keyG, keyB, keyA));
SDL_ConvertColorkeyToAlpha(convert);
}
convert->map->info.r = surface->map->info.r;
convert->map->info.g = surface->map->info.g;
Expand Down
4 changes: 0 additions & 4 deletions src/video/SDL_video.c
Expand Up @@ -46,9 +46,6 @@
#endif
#endif /* SDL_VIDEO_OPENGL */

/* From SDL_surface.c */
extern void SDL_ConvertColorkeyToAlpha(SDL_Surface * surface);

/* Available video drivers */
static VideoBootStrap *bootstrap[] = {
#if SDL_VIDEO_DRIVER_COCOA
Expand Down Expand Up @@ -1588,7 +1585,6 @@ SDL_CreateTextureFromSurface(Uint32 format, SDL_Surface * surface)
}
dst = SDL_ConvertSurface(surface, dst_fmt, 0);
if (dst) {
SDL_ConvertColorkeyToAlpha(dst);
SDL_UpdateTexture(textureID, NULL, dst->pixels, dst->pitch);
SDL_FreeSurface(dst);
}
Expand Down

0 comments on commit 335c01a

Please sign in to comment.