- added ability to use static SDL2 library

This is intended for developers only, e.g. for testing SDL backend on macOS
This commit is contained in:
alexey.lysiuk 2020-01-09 15:37:01 +02:00
parent 442f953d67
commit 1bc67cf7b9

View file

@ -62,6 +62,13 @@
// MACROS ------------------------------------------------------------------ // MACROS ------------------------------------------------------------------
// Requires SDL 2.0.6 or newer
//#define SDL2_STATIC_LIBRARY
#if defined SDL2_STATIC_LIBRARY && defined HAVE_VULKAN
#include <SDL_vulkan.h>
#endif // SDL2_STATIC_LIBRARY && HAVE_VULKAN
// TYPES ------------------------------------------------------------------- // TYPES -------------------------------------------------------------------
// PUBLIC FUNCTION PROTOTYPES ---------------------------------------------- // PUBLIC FUNCTION PROTOTYPES ----------------------------------------------
@ -113,11 +120,20 @@ CCMD(vid_list_sdl_render_drivers)
namespace Priv 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"); FModule library("SDL2");
#define SDL2_OPTIONAL_FUNCTION(RESULT, NAME, ...) \ #define SDL2_OPTIONAL_FUNCTION(RESULT, NAME, ...) \
static TOptProc<library, RESULT(*)(__VA_ARGS__)> NAME("SDL_" #NAME) static TOptProc<library, RESULT(*)(__VA_ARGS__)> NAME("SDL_" #NAME)
#endif // SDL2_STATIC_LIBRARY
SDL2_OPTIONAL_FUNCTION(int, GetWindowBordersSize, SDL_Window *window, int *top, int *left, int *bottom, int *right); SDL2_OPTIONAL_FUNCTION(int, GetWindowBordersSize, SDL_Window *window, int *top, int *left, int *bottom, int *right);
#ifdef HAVE_VULKAN #ifdef HAVE_VULKAN
SDL2_OPTIONAL_FUNCTION(void, Vulkan_GetDrawableSize, SDL_Window *window, int *width, int *height); SDL2_OPTIONAL_FUNCTION(void, Vulkan_GetDrawableSize, SDL_Window *window, int *width, int *height);
@ -408,11 +424,13 @@ SDLVideo::SDLVideo ()
return; return;
} }
#ifndef SDL2_STATIC_LIBRARY
// Load optional SDL functions // Load optional SDL functions
if (!Priv::library.IsLoaded()) if (!Priv::library.IsLoaded())
{ {
Priv::library.Load({ "libSDL2-2.0.so.0", "libSDL2-2.0.so", "libSDL2.so" }); Priv::library.Load({ "libSDL2-2.0.so.0", "libSDL2-2.0.so", "libSDL2.so" });
} }
#endif // !SDL2_STATIC_LIBRARY
#ifdef HAVE_VULKAN #ifdef HAVE_VULKAN
Priv::vulkanEnabled = vid_preferbackend == 1 Priv::vulkanEnabled = vid_preferbackend == 1