projects
/
rocksndiamonds.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
30bda8e
)
added support for alpha channel transparency for global animation images
author
Holger Schemel
<info@artsoft.org>
Thu, 10 Mar 2016 23:18:44 +0000
(
00:18
+0100)
committer
Holger Schemel
<info@artsoft.org>
Thu, 10 Mar 2016 23:18:44 +0000
(
00:18
+0100)
src/libgame/sdl.c
patch
|
blob
|
history
diff --git
a/src/libgame/sdl.c
b/src/libgame/sdl.c
index dc866db69ef25f0ab53bd9e74a05bf5c0aaef5ce..d11636646c90b0e9ac913b494a993a9464e535ec 100644
(file)
--- a/
src/libgame/sdl.c
+++ b/
src/libgame/sdl.c
@@
-278,15
+278,23
@@
boolean SDLSetNativeSurface(SDL_Surface **surface)
SDL_Surface *SDLGetNativeSurface(SDL_Surface *surface)
{
SDL_Surface *SDLGetNativeSurface(SDL_Surface *surface)
{
+ SDL_PixelFormat format;
SDL_Surface *new_surface;
if (surface == NULL)
return NULL;
if (backbuffer && backbuffer->surface)
SDL_Surface *new_surface;
if (surface == NULL)
return NULL;
if (backbuffer && backbuffer->surface)
- new_surface = SDL_ConvertSurface(surface, backbuffer->surface->format, 0);
+ {
+ format = *backbuffer->surface->format;
+ format.Amask = surface->format->Amask; // keep alpha channel
+ }
else
else
- new_surface = SDL_ConvertSurface(surface, surface->format, 0);
+ {
+ format = *surface->format;
+ }
+
+ new_surface = SDL_ConvertSurface(surface, &format, 0);
if (new_surface == NULL)
Error(ERR_EXIT, "SDL_ConvertSurface() failed: %s", SDL_GetError());
if (new_surface == NULL)
Error(ERR_EXIT, "SDL_ConvertSurface() failed: %s", SDL_GetError());
@@
-2462,8
+2470,9
@@
Bitmap *SDLLoadImage(char *filename)
UPDATE_BUSY_STATE();
/* create native transparent surface for current image */
UPDATE_BUSY_STATE();
/* create native transparent surface for current image */
- SDL_SetColorKey(sdl_image_tmp, SET_TRANSPARENT_PIXEL,
- SDL_MapRGB(sdl_image_tmp->format, 0x00, 0x00, 0x00));
+ if (sdl_image_tmp->format->Amask == 0)
+ SDL_SetColorKey(sdl_image_tmp, SET_TRANSPARENT_PIXEL,
+ SDL_MapRGB(sdl_image_tmp->format, 0x00, 0x00, 0x00));
if ((new_bitmap->surface_masked = SDLGetNativeSurface(sdl_image_tmp)) == NULL)
{
if ((new_bitmap->surface_masked = SDLGetNativeSurface(sdl_image_tmp)) == NULL)
{