Fixes bug #2040, prepare SDL_GL_CONTEXT_EGL for deprecation on v2.1
SDL_GL_CONTEXT_EGL = 1 is now internally treated as profile_mask = SDL_GL_CONTEXT_PROFILE_ES
--- a/src/render/opengles/SDL_render_gles.c Thu Aug 29 14:03:44 2013 -0300
+++ b/src/render/opengles/SDL_render_gles.c Thu Aug 29 15:02:32 2013 -0300
@@ -280,7 +280,7 @@
GLint value;
Uint32 windowFlags;
- SDL_GL_SetAttribute(SDL_GL_CONTEXT_EGL, 1);
+ SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 1);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1);
--- a/src/render/opengles2/SDL_render_gles2.c Thu Aug 29 14:03:44 2013 -0300
+++ b/src/render/opengles2/SDL_render_gles2.c Thu Aug 29 15:02:32 2013 -0300
@@ -1628,7 +1628,7 @@
Uint32 windowFlags;
GLint window_framebuffer;
- SDL_GL_SetAttribute(SDL_GL_CONTEXT_EGL, 1);
+ SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
--- a/src/video/SDL_video.c Thu Aug 29 14:03:44 2013 -0300
+++ b/src/video/SDL_video.c Thu Aug 29 15:02:32 2013 -0300
@@ -477,26 +477,21 @@
_this->gl_config.multisamplesamples = 0;
_this->gl_config.retained_backing = 1;
_this->gl_config.accelerated = -1; /* accelerated or not, both are fine */
+ _this->gl_config.profile_mask = 0;
#if SDL_VIDEO_OPENGL
_this->gl_config.major_version = 2;
_this->gl_config.minor_version = 1;
- _this->gl_config.use_egl = 0;
#elif SDL_VIDEO_OPENGL_ES
_this->gl_config.major_version = 1;
_this->gl_config.minor_version = 1;
-#if SDL_VIDEO_OPENGL_EGL
- _this->gl_config.use_egl = 1;
-#endif
+ _this->gl_config.profile_mask = SDL_GL_CONTEXT_PROFILE_ES;
#elif SDL_VIDEO_OPENGL_ES2
_this->gl_config.major_version = 2;
_this->gl_config.minor_version = 0;
-#if SDL_VIDEO_OPENGL_EGL
- _this->gl_config.use_egl = 1;
-#endif
-
+ _this->gl_config.profile_mask = SDL_GL_CONTEXT_PROFILE_ES;
#endif
_this->gl_config.flags = 0;
- _this->gl_config.profile_mask = 0;
+
_this->gl_config.share_with_current_context = 0;
_this->current_glwin_tls = SDL_TLSCreate();
@@ -2516,7 +2511,12 @@
_this->gl_config.minor_version = value;
break;
case SDL_GL_CONTEXT_EGL:
- _this->gl_config.use_egl = value;
+ /* FIXME: SDL_GL_CONTEXT_EGL to be deprecated in SDL 2.1 */
+ if (value != 0) {
+ SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
+ } else {
+ SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, 0);
+ };
break;
case SDL_GL_CONTEXT_FLAGS:
if( value & ~(SDL_GL_CONTEXT_DEBUG_FLAG |
@@ -2686,8 +2686,14 @@
return 0;
}
case SDL_GL_CONTEXT_EGL:
+ /* FIXME: SDL_GL_CONTEXT_EGL to be deprecated in SDL 2.1 */
{
- *value = _this->gl_config.use_egl;
+ if (_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES) {
+ *value = 1;
+ }
+ else {
+ *value = 0;
+ }
return 0;
}
case SDL_GL_CONTEXT_FLAGS:
--- a/src/video/x11/SDL_x11opengl.c Thu Aug 29 14:03:44 2013 -0300
+++ b/src/video/x11/SDL_x11opengl.c Thu Aug 29 15:02:32 2013 -0300
@@ -210,36 +210,31 @@
/* 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 we need a GL ES context and there's no
+ * GLX_EXT_create_context_es2_profile extension, switch over to X11_GLES functions
+ */
+ if (_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES &&
+ ! _this->gl_data->HAS_GLX_EXT_create_context_es2_profile ) {
#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);
+ 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");
+ return SDL_SetError("SDL not configured with EGL support");
#endif
- }
}
return 0;
--- a/src/video/x11/SDL_x11opengles.c Thu Aug 29 14:03:44 2013 -0300
+++ b/src/video/x11/SDL_x11opengles.c Thu Aug 29 15:02:32 2013 -0300
@@ -33,8 +33,8 @@
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
- /* If SDL_GL_CONTEXT_EGL has been changed to 0, switch over to X11_GL functions */
- if (_this->gl_config.use_egl == 0) {
+ /* If the profile requested is not GL ES, switch over to X11_GL functions */
+ if (_this->gl_config.profile_mask != SDL_GL_CONTEXT_PROFILE_ES) {
#if SDL_VIDEO_OPENGL_GLX
_this->GL_LoadLibrary = X11_GL_LoadLibrary;
_this->GL_GetProcAddress = X11_GL_GetProcAddress;
--- a/src/video/x11/SDL_x11window.c Thu Aug 29 14:03:44 2013 -0300
+++ b/src/video/x11/SDL_x11window.c Thu Aug 29 15:02:32 2013 -0300
@@ -366,10 +366,11 @@
#if SDL_VIDEO_OPENGL_GLX || SDL_VIDEO_OPENGL_EGL
if (window->flags & SDL_WINDOW_OPENGL) {
- XVisualInfo *vinfo;
+ XVisualInfo *vinfo = NULL;
#if SDL_VIDEO_OPENGL_EGL
- if (_this->gl_config.use_egl == 1) {
+ if (_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES &&
+ ( !_this->gl_data || ! _this->gl_data->HAS_GLX_EXT_create_context_es2_profile )) {
vinfo = X11_GLES_GetVisual(_this, display, screen);
} else
#endif
@@ -378,6 +379,7 @@
vinfo = X11_GL_GetVisual(_this, display, screen);
#endif
}
+
if (!vinfo) {
return -1;
}
@@ -551,7 +553,9 @@
windowdata = (SDL_WindowData *) window->driverdata;
#if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
- if ((window->flags & SDL_WINDOW_OPENGL) && (_this->gl_config.use_egl == 1)) {
+ if ((window->flags & SDL_WINDOW_OPENGL) &&
+ _this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES &&
+ (!_this->gl_data || ! _this->gl_data->HAS_GLX_EXT_create_context_es2_profile) ) {
if (!_this->egl_data) {
XDestroyWindow(display, w);
return -1;