diff options
author | Gabriel Jacobo <gabomdq@gmail.com> | 2013-08-19 16:29:46 -0300 |
---|---|---|
committer | Gabriel Jacobo <gabomdq@gmail.com> | 2013-08-19 16:29:46 -0300 |
commit | 84f07d804a98c7b484de39c892392049cf1b3d99 (patch) | |
tree | b0918da8d71077ab9bd21793b8db84b59741f214 /src/video/x11/SDL_x11opengl.c | |
parent | ae735be7ec3f74595167b9edb037de5c5da6f3e4 (diff) |
Fixes bug #2037, common EGL code for Android and X11
Diffstat (limited to 'src/video/x11/SDL_x11opengl.c')
-rw-r--r-- | src/video/x11/SDL_x11opengl.c | 56 |
1 files changed, 37 insertions, 19 deletions
diff --git a/src/video/x11/SDL_x11opengl.c b/src/video/x11/SDL_x11opengl.c index 2eaed86980..6ddc0de7e9 100644 --- a/src/video/x11/SDL_x11opengl.c +++ b/src/video/x11/SDL_x11opengl.c @@ -140,25 +140,6 @@ X11_GL_LoadLibrary(_THIS, const char *path) return SDL_SetError("OpenGL context already created"); } - /* If SDL_GL_CONTEXT_EGL has been changed to 1, switch over to X11_GLES functions */ - if (_this->gl_config.use_egl == 1) { -#if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2 - _this->GL_LoadLibrary = X11_GLES_LoadLibrary; - _this->GL_GetProcAddress = X11_GLES_GetProcAddress; - _this->GL_UnloadLibrary = X11_GLES_UnloadLibrary; - _this->GL_CreateContext = X11_GLES_CreateContext; - _this->GL_MakeCurrent = X11_GLES_MakeCurrent; - _this->GL_SetSwapInterval = X11_GLES_SetSwapInterval; - _this->GL_GetSwapInterval = X11_GLES_GetSwapInterval; - _this->GL_SwapWindow = X11_GLES_SwapWindow; - _this->GL_DeleteContext = X11_GLES_DeleteContext; - return X11_GLES_LoadLibrary(_this, path); -#else - return SDL_SetError("SDL not configured with OpenGL ES/EGL support"); -#endif - } - - /* Load the OpenGL library */ if (path == NULL) { path = SDL_getenv("SDL_OPENGL_LIBRARY"); @@ -228,6 +209,38 @@ X11_GL_LoadLibrary(_THIS, const char *path) /* Initialize extensions */ X11_GL_InitExtensions(_this); + + /* If SDL_GL_CONTEXT_EGL has been changed to 1, and there's + * no GLX_EXT_create_context_es2_profile extension switch over to X11_GLES functions */ + if (_this->gl_config.use_egl == 1) { + if (_this->gl_data->HAS_GLX_EXT_create_context_es2_profile) { + /* We cheat a little bit here by using GLX instead of EGL + * to improve our chances of getting hardware acceleration */ + _this->gl_config.use_egl = 0; + _this->gl_config.profile_mask = SDL_GL_CONTEXT_PROFILE_ES; + } else { +#if SDL_VIDEO_OPENGL_EGL + X11_GL_UnloadLibrary(_this); + /* Better avoid conflicts! */ + if (_this->gl_config.dll_handle != NULL ) { + GL_UnloadObject(_this->gl_config.dll_handle); + _this->gl_config.dll_handle = NULL; + } + _this->GL_LoadLibrary = X11_GLES_LoadLibrary; + _this->GL_GetProcAddress = X11_GLES_GetProcAddress; + _this->GL_UnloadLibrary = X11_GLES_UnloadLibrary; + _this->GL_CreateContext = X11_GLES_CreateContext; + _this->GL_MakeCurrent = X11_GLES_MakeCurrent; + _this->GL_SetSwapInterval = X11_GLES_SetSwapInterval; + _this->GL_GetSwapInterval = X11_GLES_GetSwapInterval; + _this->GL_SwapWindow = X11_GLES_SwapWindow; + _this->GL_DeleteContext = X11_GLES_DeleteContext; + return X11_GLES_LoadLibrary(_this, NULL); +#else + return SDL_SetError("SDL not configured with EGL support"); +#endif + } + } return 0; } @@ -369,6 +382,11 @@ X11_GL_InitExtensions(_THIS) if (HasExtension("GLX_EXT_visual_info", extensions)) { _this->gl_data->HAS_GLX_EXT_visual_info = SDL_TRUE; } + + /* Check for GLX_EXT_create_context_es2_profile */ + if (HasExtension("GLX_EXT_create_context_es2_profile", extensions)) { + _this->gl_data->HAS_GLX_EXT_create_context_es2_profile = SDL_TRUE; + } if (context) { _this->gl_data->glXMakeCurrent(display, None, NULL); |