From 75da16d99e10fbbef1ace5882ad8eb048ad09213 Mon Sep 17 00:00:00 2001 From: Michael Martin Date: Fri, 3 Apr 2020 23:30:10 -0700 Subject: [PATCH] Fix SDL2 build errors --- sc2/src/libs/graphics/sdl/scalers.c | 2 +- sc2/src/libs/graphics/sdl/sdl2_pure.c | 11 ++++++ sc2/src/libs/graphics/sdl/sdl_common.c | 52 +------------------------- sc2/src/libs/input/sdl/input.c | 17 +++------ 4 files changed, 20 insertions(+), 62 deletions(-) diff --git a/sc2/src/libs/graphics/sdl/scalers.c b/sc2/src/libs/graphics/sdl/scalers.c index 2acb21ee2..751dae342 100644 --- a/sc2/src/libs/graphics/sdl/scalers.c +++ b/sc2/src/libs/graphics/sdl/scalers.c @@ -213,7 +213,7 @@ Scale_PrepPlatform (int flags, const SDL_PixelFormat* fmt) // first match wins // add better platform techs to the top #ifdef MMX_ASM - if ( (!force_platform && (SDL_HasSSE () || SDL_HasMMXExt ())) + if ( (!force_platform && (SDL_HasSSE () || SDL_HasMMX ())) || force_platform == PLATFORM_SSE) { log_add (log_Info, "Screen scalers are using SSE/MMX-Ext/MMX code"); diff --git a/sc2/src/libs/graphics/sdl/sdl2_pure.c b/sc2/src/libs/graphics/sdl/sdl2_pure.c index 7177f9752..0d7c9ec42 100644 --- a/sc2/src/libs/graphics/sdl/sdl2_pure.c +++ b/sc2/src/libs/graphics/sdl/sdl2_pure.c @@ -260,6 +260,17 @@ TFB_Pure_InitGraphics (int driver, int flags, int width, int height) return 0; } +void +TFB_Pure_UninitGraphics (void) +{ + if (renderer) { + SDL_DestroyRenderer (renderer); + } + if (window) { + SDL_DestroyWindow (window); + } +} + static void TFB_SDL2_UploadTransitionScreen (void) { diff --git a/sc2/src/libs/graphics/sdl/sdl_common.c b/sc2/src/libs/graphics/sdl/sdl_common.c index 79f165da9..3f57084a6 100644 --- a/sc2/src/libs/graphics/sdl/sdl_common.c +++ b/sc2/src/libs/graphics/sdl/sdl_common.c @@ -50,61 +50,13 @@ TFB_GRAPHICS_BACKEND *graphics_backend = NULL; volatile int QuitPosted = 0; volatile int GameActive = 1; // Track the SDL_ACTIVEEVENT state SDL_APPACTIVE -int -TFB_ReInitGraphics (int driver, int flags, int width, int height) -{ - int result; - int togglefullscreen = 0; - char caption[200]; - - if (GfxFlags == (flags ^ TFB_GFXFLAGS_FULLSCREEN) && - driver == GraphicsDriver && - width == ScreenWidthActual && height == ScreenHeightActual) - { - togglefullscreen = 1; - } - - GfxFlags = flags; - - if (driver == TFB_GFXDRIVER_SDL_OPENGL) - { -#ifdef HAVE_OPENGL - result = TFB_GL_ConfigureVideo (driver, flags, width, height, - togglefullscreen); -#else - driver = TFB_GFXDRIVER_SDL_PURE; - log_add (log_Warning, "OpenGL support not compiled in," - " so using pure SDL driver"); - result = TFB_Pure_ConfigureVideo (driver, flags, width, height, - togglefullscreen); -#endif - } - else - { - result = TFB_Pure_ConfigureVideo (driver, flags, width, height, - togglefullscreen); - } - - sprintf (caption, "The Ur-Quan Masters v%d.%d.%d%s", - UQM_MAJOR_VERSION, UQM_MINOR_VERSION, - UQM_PATCH_VERSION, UQM_EXTRA_VERSION); - SDL_WM_SetCaption (caption, NULL); - - if (flags & TFB_GFXFLAGS_FULLSCREEN) - SDL_ShowCursor (SDL_DISABLE); - else - SDL_ShowCursor (SDL_ENABLE); - - return result; -} - int TFB_InitGraphics (int driver, int flags, int width, int height) { - int i, result; + int result, i; char caption[200]; - /* Null out screen pointers for the first time */ + /* Null out screen pointers the first time */ for (i = 0; i < TFB_GFX_NUMSCREENS; i++) { SDL_Screens[i] = NULL; diff --git a/sc2/src/libs/input/sdl/input.c b/sc2/src/libs/input/sdl/input.c index 82d911f6e..6f2f8c69b 100644 --- a/sc2/src/libs/input/sdl/input.c +++ b/sc2/src/libs/input/sdl/input.c @@ -220,19 +220,13 @@ TFB_SetInputVectors (volatile int menu[], int num_menu_, volatile int flight[], num_flight = num_flight_; } +#ifdef HAVE_JOYSTICK + static void initJoystick (void) { int nJoysticks; -#if SDL_MAJOR_VERSION == 1 - SDL_EnableUNICODE(1); - (void)SDL_GetKeyState (&num_keys); - kbdstate = (int *)HMalloc (sizeof (int) * (num_keys + 1)); -#endif - - -#ifdef HAVE_JOYSTICK if ((SDL_InitSubSystem(SDL_INIT_JOYSTICK)) == -1) { log_add (log_Fatal, "Couldn't initialize joystick subsystem: %s", @@ -269,14 +263,15 @@ TFB_InitInput (int driver, int flags) (void)driver; (void)flags; +#if SDL_MAJOR_VERSION == 1 SDL_EnableUNICODE(1); (void)SDL_GetKeyState (&num_keys); kbdstate = (int *)HMalloc (sizeof (int) * (num_keys + 1)); - +#endif -#ifdef HAVE_JOYSTICK +#ifdef HAVE_JOYSTICK initJoystick (); -#endif /* HAVE_JOYSTICK */ +#endif in_character_mode = FALSE; resetKeyboardState ();