Fixed bug 3724 - Allow Angle Static Link
authorSam Lantinga <slouken@libsdl.org>
Sun, 27 Aug 2017 19:05:57 -0700
changeset 113632d3d35b2c95a
parent 11361 b83e2eaed190
child 11364 ec27c4fd6880
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
src/video/SDL_egl.c
     1.1 --- a/include/SDL_egl.h	Sun Aug 27 19:00:03 2017 -0700
     1.2 +++ b/include/SDL_egl.h	Sun Aug 27 19:05:57 2017 -0700
     1.3 @@ -132,7 +132,7 @@
     1.4  *-------------------------------------------------------------------------
     1.5  * This precedes the return type of the function in the function prototype.
     1.6  */
     1.7 -#if defined(_WIN32) && !defined(__SCITECH_SNAP__)
     1.8 +#if defined(_WIN32) && !defined(__SCITECH_SNAP__) && !defined(SDL_VIDEO_STATIC_ANGLE)
     1.9  #   define KHRONOS_APICALL __declspec(dllimport)
    1.10  #elif defined (__SYMBIAN32__)
    1.11  #   define KHRONOS_APICALL IMPORT_C
     2.1 --- a/src/video/SDL_egl.c	Sun Aug 27 19:00:03 2017 -0700
     2.2 +++ b/src/video/SDL_egl.c	Sun Aug 27 19:05:57 2017 -0700
     2.3 @@ -72,12 +72,17 @@
     2.4  #define DEFAULT_OGL_ES "libGLESv1_CM.so.1"
     2.5  #endif /* SDL_VIDEO_DRIVER_RPI */
     2.6  
     2.7 +#ifdef SDL_VIDEO_STATIC_ANGLE
     2.8 +#define LOAD_FUNC(NAME) \
     2.9 +_this->egl_data->NAME = (void *)NAME;
    2.10 +#else
    2.11  #define LOAD_FUNC(NAME) \
    2.12  _this->egl_data->NAME = SDL_LoadFunction(_this->egl_data->dll_handle, #NAME); \
    2.13  if (!_this->egl_data->NAME) \
    2.14  { \
    2.15      return SDL_SetError("Could not retrieve EGL function " #NAME); \
    2.16  }
    2.17 +#endif
    2.18  
    2.19  static const char * SDL_EGL_GetErrorName(EGLint eglErrorCode)
    2.20  {
    2.21 @@ -275,6 +280,7 @@
    2.22      }
    2.23  #endif
    2.24  
    2.25 +#ifndef SDL_VIDEO_STATIC_ANGLE
    2.26      /* A funny thing, loading EGL.so first does not work on the Raspberry, so we load libGL* first */
    2.27      path = SDL_getenv("SDL_VIDEO_GL_DRIVER");
    2.28      if (path != NULL) {
    2.29 @@ -330,6 +336,7 @@
    2.30          }
    2.31          SDL_ClearError();
    2.32      }
    2.33 +#endif
    2.34  
    2.35      _this->egl_data->dll_handle = dll_handle;
    2.36