From 6b6c9eb24c469d8b1fea8d76172b549b45f7cd77 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Tue, 19 May 2020 18:03:12 +0200 Subject: [PATCH] added workaround for a bug in SDL 2.0.12 which prevents transparency Unfortunately, the current stable release version 2.0.12 of the SDL library used by R'n'D has a critical bug that causes all transparent images in R'n'D to be opaque, which hurts the game graphics at various places. The cause of this bug is in SDL_ConvertSurface(), which does not copy the color key anymore. The bug is documented in the SDL bug tracking system as follows: https://bugzilla.libsdl.org/show_bug.cgi?id=2979 The bug will be fixed in the next stable release of the SDL library. This workaround checks if a converted surface should have a color key, and explicitly sets it if it is missing in the newly created surface. --- src/libgame/sdl.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/libgame/sdl.c b/src/libgame/sdl.c index 7fb650f1..457f567a 100644 --- a/src/libgame/sdl.c +++ b/src/libgame/sdl.c @@ -353,6 +353,11 @@ SDL_Surface *SDLGetNativeSurface(SDL_Surface *surface) if (new_surface == NULL) Error(ERR_EXIT, "SDL_ConvertSurface() failed: %s", SDL_GetError()); + // workaround for a bug in SDL 2.0.12 (which does not convert the color key) + if (SDLHasColorKey(surface) && !SDLHasColorKey(new_surface)) + SDL_SetColorKey(new_surface, SET_TRANSPARENT_PIXEL, + SDLGetColorKey(surface)); + return new_surface; } -- 2.34.1