diff --git a/sc2/src/libs/graphics/sdl/opengl.c b/sc2/src/libs/graphics/sdl/opengl.c index 3dc4d9e96..a7d506e86 100644 --- a/sc2/src/libs/graphics/sdl/opengl.c +++ b/sc2/src/libs/graphics/sdl/opengl.c @@ -172,7 +172,7 @@ TFB_GL_ConfigureVideo (int driver, int flags, int width, int height, int togglef for (i = 0; i < TFB_GFX_NUMSCREENS; i++) { - if (0 != ReInit_Screen (&SDL_Screens[i], format_conv_surf, + if (0 != SDL1_ReInit_Screen (&SDL_Screens[i], format_conv_surf, ScreenWidth, ScreenHeight)) return -1; } @@ -201,7 +201,7 @@ TFB_GL_ConfigureVideo (int driver, int flags, int width, int height, int togglef { if (!GL_Screens[i].active) continue; - if (0 != ReInit_Screen (&GL_Screens[i].scaled, format_conv_surf, + if (0 != SDL1_ReInit_Screen (&GL_Screens[i].scaled, format_conv_surf, ScreenWidth * 2, ScreenHeight * 2)) return -1; } diff --git a/sc2/src/libs/graphics/sdl/pure.c b/sc2/src/libs/graphics/sdl/pure.c index 4e4426acc..07631a299 100644 --- a/sc2/src/libs/graphics/sdl/pure.c +++ b/sc2/src/libs/graphics/sdl/pure.c @@ -202,7 +202,7 @@ TFB_Pure_ConfigureVideo (int driver, int flags, int width, int height, int toggl for (i = 0; i < TFB_GFX_NUMSCREENS; i++) { - if (0 != ReInit_Screen (&SDL_Screens[i], format_conv_surf, + if (0 != SDL1_ReInit_Screen (&SDL_Screens[i], format_conv_surf, ScreenWidth, ScreenHeight)) return -1; } @@ -210,19 +210,19 @@ TFB_Pure_ConfigureVideo (int driver, int flags, int width, int height, int toggl SDL_Screen = SDL_Screens[0]; TransitionScreen = SDL_Screens[2]; - if (0 != ReInit_Screen (&fade_color_surface, format_conv_surf, + if (0 != SDL1_ReInit_Screen (&fade_color_surface, format_conv_surf, ScreenWidth, ScreenHeight)) return -1; fade_color = SDL_MapRGB (fade_color_surface->format, 0, 0, 0); SDL_FillRect (fade_color_surface, NULL, fade_color); - if (0 != ReInit_Screen (&fade_temp, format_conv_surf, + if (0 != SDL1_ReInit_Screen (&fade_temp, format_conv_surf, ScreenWidth, ScreenHeight)) return -1; if (ScreenWidthActual > ScreenWidth || ScreenHeightActual > ScreenHeight) { - if (0 != ReInit_Screen (&scaled_display, format_conv_surf, + if (0 != SDL1_ReInit_Screen (&scaled_display, format_conv_surf, ScreenWidthActual, ScreenHeightActual)) return -1; diff --git a/sc2/src/libs/graphics/sdl/sdl1_common.c b/sc2/src/libs/graphics/sdl/sdl1_common.c index f5c7c2246..7791e8ab3 100644 --- a/sc2/src/libs/graphics/sdl/sdl1_common.c +++ b/sc2/src/libs/graphics/sdl/sdl1_common.c @@ -212,4 +212,28 @@ TFB_SupportsHardwareScaling (void) #endif } +static SDL_Surface * +Create_Screen (SDL_Surface *templat, int w, int h) +{ + SDL_Surface *newsurf = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h + templat->format->BitsPerPixel, + templat->format->Rmask, templat->format->GMask, + templat->format->Bmask, 0); + if (newsurf == 0) { + log_add (log_Error, "Couldn't create screen buffes: %s", + SDL_GetError()); + } + return newsurf; +} + +int +SDL1_ReInit_Screen (SDL_Surface **screen, SDL_Surface *templat, int w, int h) +{ + if (*screen) { + SDL_FreeSurface (*screen); + } + *screen = Create_Screen (templat, w, h); + + return *screen == 0 ? -1 : 0; +} #endif diff --git a/sc2/src/libs/graphics/sdl/sdl_common.h b/sc2/src/libs/graphics/sdl/sdl_common.h index 63e09d306..76d1cb663 100644 --- a/sc2/src/libs/graphics/sdl/sdl_common.h +++ b/sc2/src/libs/graphics/sdl/sdl_common.h @@ -55,8 +55,9 @@ int TFB_SetColorKey (SDL_Surface *surface, Uint32 key, int rleaccel); int TFB_DisableColorKey (SDL_Surface *surface); int TFB_SetColors (SDL_Surface *surface, SDL_Color *colors, int firstcolor, int ncolors); -SDL_Surface* Create_Screen (SDL_Surface *templat, int w, int h); -int ReInit_Screen (SDL_Surface **screen, SDL_Surface *templat, int w, int h); +#if SDL_MAJOR_VERSION == 1 +int SDL1_ReInit_Screen (SDL_Surface **screen, SDL_Surface *templat, int w, int h); +#endif void UnInit_Screen (SDL_Surface **screen); #endif