From 1bc67cf7b9fe0475f287b15bc67a3992907a837b Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Thu, 9 Jan 2020 15:37:01 +0200 Subject: [PATCH] - added ability to use static SDL2 library This is intended for developers only, e.g. for testing SDL backend on macOS --- src/posix/sdl/sdlglvideo.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/posix/sdl/sdlglvideo.cpp b/src/posix/sdl/sdlglvideo.cpp index 39931c28e..5cfc08e8a 100644 --- a/src/posix/sdl/sdlglvideo.cpp +++ b/src/posix/sdl/sdlglvideo.cpp @@ -62,6 +62,13 @@ // MACROS ------------------------------------------------------------------ +// Requires SDL 2.0.6 or newer +//#define SDL2_STATIC_LIBRARY + +#if defined SDL2_STATIC_LIBRARY && defined HAVE_VULKAN +#include +#endif // SDL2_STATIC_LIBRARY && HAVE_VULKAN + // TYPES ------------------------------------------------------------------- // PUBLIC FUNCTION PROTOTYPES ---------------------------------------------- @@ -113,11 +120,20 @@ CCMD(vid_list_sdl_render_drivers) namespace Priv { +#ifdef SDL2_STATIC_LIBRARY + +#define SDL2_OPTIONAL_FUNCTION(RESULT, NAME, ...) \ + RESULT(*NAME)(__VA_ARGS__) = SDL_ ## NAME + +#else // !SDL2_STATIC_LIBRARY + FModule library("SDL2"); #define SDL2_OPTIONAL_FUNCTION(RESULT, NAME, ...) \ static TOptProc NAME("SDL_" #NAME) +#endif // SDL2_STATIC_LIBRARY + SDL2_OPTIONAL_FUNCTION(int, GetWindowBordersSize, SDL_Window *window, int *top, int *left, int *bottom, int *right); #ifdef HAVE_VULKAN SDL2_OPTIONAL_FUNCTION(void, Vulkan_GetDrawableSize, SDL_Window *window, int *width, int *height); @@ -408,11 +424,13 @@ SDLVideo::SDLVideo () return; } +#ifndef SDL2_STATIC_LIBRARY // Load optional SDL functions if (!Priv::library.IsLoaded()) { Priv::library.Load({ "libSDL2-2.0.so.0", "libSDL2-2.0.so", "libSDL2.so" }); } +#endif // !SDL2_STATIC_LIBRARY #ifdef HAVE_VULKAN Priv::vulkanEnabled = vid_preferbackend == 1