Skip to content

Commit

Permalink
Add NATIVE_TOOLKIT_STATIC_ANGLE switch to allow the angle library to …
Browse files Browse the repository at this point in the history
…be statically linked
  • Loading branch information
hughsando committed Apr 16, 2017
1 parent 953cc95 commit a78c07d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
1 change: 1 addition & 0 deletions files.xml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@

<compilerflag value="-DUSING_GENERATED_CONFIG_H" />
<compilerflag value="-DNATIVE_TOOLKIT_SDL_ANGLE" if="NATIVE_TOOLKIT_SDL_ANGLE" />
<compilerflag value="-DNATIVE_TOOLKIT_STATIC_ANGLE" if="NATIVE_TOOLKIT_STATIC_ANGLE" />

</section>

Expand Down
5 changes: 4 additions & 1 deletion include/SDL_egl.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,10 @@
*-------------------------------------------------------------------------
* This precedes the return type of the function in the function prototype.
*/
#if defined(_WIN32) && !defined(__SCITECH_SNAP__)
#if defined(NATIVE_TOOLKIT_STATIC_ANGLE)
// not "dllimport" - just extern
# define KHRONOS_APICALL
#elif defined(_WIN32) && !defined(__SCITECH_SNAP__)
# define KHRONOS_APICALL __declspec(dllimport)
#elif defined (__SYMBIAN32__)
# define KHRONOS_APICALL IMPORT_C
Expand Down
11 changes: 10 additions & 1 deletion src/video/SDL_egl.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,18 @@
#define DEFAULT_OGL_ES "libGLESv1_CM.so.1"
#endif /* SDL_VIDEO_DRIVER_RPI */

#ifdef NATIVE_TOOLKIT_STATIC_ANGLE
// Just resolve the symbol directly
#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

/* EGL implementation of SDL OpenGL ES support */
#ifdef EGL_KHR_create_context
Expand Down Expand Up @@ -189,12 +195,13 @@ SDL_EGL_LoadLibrary(_THIS, const char *egl_path, NativeDisplayType native_displa
}
#endif

// Do not need to load dll if we static link ...
#ifndef NATIVE_TOOLKIT_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) {
egl_dll_handle = SDL_LoadObject(path);
}

if (egl_dll_handle == NULL) {
if (_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES) {
if (_this->gl_config.major_version > 1) {
Expand Down Expand Up @@ -245,6 +252,8 @@ SDL_EGL_LoadLibrary(_THIS, const char *egl_path, NativeDisplayType native_displa
SDL_ClearError();
}

#endif // NATIVE_TOOLKIT_STATIC_ANGLE

_this->egl_data->dll_handle = dll_handle;

/* Load new function pointers */
Expand Down
4 changes: 4 additions & 0 deletions src/video/windows/SDL_windowsopengles.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,16 @@ WIN_GLES_SetupWindow(_THIS, SDL_Window * window)
int
WIN_GLES_SetSwapInterval(_THIS, int interval)
{
#ifndef NATIVE_TOOLKIT_STATIC_ANGLE
/* FIXME: This should call SDL_EGL_SetSwapInterval, but ANGLE has a bug that prevents this
* from working if we do (the window contents freeze and don't swap properly). So, we ignore
* the request for now.
*/
SDL_Log("WARNING: Ignoring SDL_GL_SetSwapInterval call due to ANGLE bug");
return 0;
#else
return SDL_EGL_SetSwapInterval(_this, interval);
#endif
}

#endif /* SDL_VIDEO_DRIVER_WINDOWS && SDL_VIDEO_OPENGL_EGL */
Expand Down

0 comments on commit a78c07d

Please sign in to comment.