Skip to content
Permalink
Browse files

- added ability to use static SDL2 library

This is intended for developers only, e.g. for testing SDL backend on macOS
  • Loading branch information
alexey-lysiuk committed Jan 9, 2020
1 parent 442f953 commit 1bc67cf7b9fe0475f287b15bc67a3992907a837b
Showing with 18 additions and 0 deletions.
  1. +18 −0 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 <SDL_vulkan.h>
#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

This comment has been minimized.

Copy link
@Blzut3

Blzut3 Jan 13, 2020

Collaborator

I think this may be the second time I've seen something like this since FModule was added. Does FModuleMaybe<!SDL_STATIC_LIBRARY> (see gtk_dialogs.cpp) for example not work here? Or did I just do a bad job at documenting how to use the library? The point of FModule was to remove as much of the boilerplate as possible and that included toggling between static and dynamic linkage.

This comment has been minimized.

Copy link
@alexey-lysiuk

alexey-lysiuk Jan 14, 2020

Author Collaborator

I was not aware of that.


#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<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);
#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

0 comments on commit 1bc67cf

Please sign in to comment.
You can’t perform that action at this time.