From 003d491f86a2e9cd14185eebf645d573c7a198be Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sun, 27 Aug 2017 19:05:57 -0700 Subject: [PATCH] Fixed bug 3724 - Allow Angle Static Link Carlos We would like to add a switch (define) that allows us to compile Angle statically with SDL. That is, getting rid of the OpenGL DLL. Usually you need OpenGL to be loaded dynamically as DLL because implementation is provided by the system but no need with Angle. Only 2 files need modification and it shouldn't affect current behaivor: include/SDL_egl.h and src/video/SDL_egl.c, as in here https://github.com/native-toolkit/sdl/pull/10/files The flag name could be SDL_VIDEO_STATIC_ANGLE (instead of NATIVE_TOOLKIT_STATIC_ANGLE) as discussed here https://github.com/native-toolkit/sdl/pull/10 We have tested this with both Windows and UWP, using NME engine (https://github.com/haxenme/nme). Releated issue: https://bugzilla.libsdl.org/show_bug.cgi?id=1820 --- include/SDL_egl.h | 2 +- src/video/SDL_egl.c | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/include/SDL_egl.h b/include/SDL_egl.h index 65c110c67..e47fbe862 100644 --- a/include/SDL_egl.h +++ b/include/SDL_egl.h @@ -132,7 +132,7 @@ *------------------------------------------------------------------------- * This precedes the return type of the function in the function prototype. */ -#if defined(_WIN32) && !defined(__SCITECH_SNAP__) +#if defined(_WIN32) && !defined(__SCITECH_SNAP__) && !defined(SDL_VIDEO_STATIC_ANGLE) # define KHRONOS_APICALL __declspec(dllimport) #elif defined (__SYMBIAN32__) # define KHRONOS_APICALL IMPORT_C diff --git a/src/video/SDL_egl.c b/src/video/SDL_egl.c index 1e0aacf20..24ad00a90 100644 --- a/src/video/SDL_egl.c +++ b/src/video/SDL_egl.c @@ -72,12 +72,17 @@ #define DEFAULT_OGL_ES "libGLESv1_CM.so.1" #endif /* SDL_VIDEO_DRIVER_RPI */ +#ifdef SDL_VIDEO_STATIC_ANGLE +#define LOAD_FUNC(NAME) \ +_this->egl_data->NAME = (void *)NAME; +#else #define LOAD_FUNC(NAME) \ _this->egl_data->NAME = SDL_LoadFunction(_this->egl_data->dll_handle, #NAME); \ if (!_this->egl_data->NAME) \ { \ return SDL_SetError("Could not retrieve EGL function " #NAME); \ } +#endif static const char * SDL_EGL_GetErrorName(EGLint eglErrorCode) { @@ -275,6 +280,7 @@ SDL_EGL_LoadLibrary(_THIS, const char *egl_path, NativeDisplayType native_displa } #endif +#ifndef SDL_VIDEO_STATIC_ANGLE /* A funny thing, loading EGL.so first does not work on the Raspberry, so we load libGL* first */ path = SDL_getenv("SDL_VIDEO_GL_DRIVER"); if (path != NULL) { @@ -330,6 +336,7 @@ SDL_EGL_LoadLibrary(_THIS, const char *egl_path, NativeDisplayType native_displa } SDL_ClearError(); } +#endif _this->egl_data->dll_handle = dll_handle;