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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206
diff --git a/src/render/opengles/SDL_render_gles.c b/src/render/opengles/SDL_render_gles.c
index 1b3ea0f..b3ce790 100644
--- a/src/render/opengles/SDL_render_gles.c
+++ b/src/render/opengles/SDL_render_gles.c
@@ -280,7 +280,7 @@ GLES_CreateRenderer(SDL_Window * window, Uint32 flags)
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);
diff --git a/src/render/opengles2/SDL_render_gles2.c b/src/render/opengles2/SDL_render_gles2.c
index db030c6..484186e 100644
--- a/src/render/opengles2/SDL_render_gles2.c
+++ b/src/render/opengles2/SDL_render_gles2.c
@@ -1628,7 +1628,7 @@ GLES2_CreateRenderer(SDL_Window *window, Uint32 flags)
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);
diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c
index 53e6e02..72bd074 100644
--- a/src/video/SDL_video.c
+++ b/src/video/SDL_video.c
@@ -477,26 +477,21 @@ SDL_VideoInit(const char *driver_name)
_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 @@ SDL_GL_SetAttribute(SDL_GLattr attr, int value)
_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 @@ SDL_GL_GetAttribute(SDL_GLattr attr, int *value)
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:
diff --git a/src/video/x11/SDL_x11opengl.c b/src/video/x11/SDL_x11opengl.c
index 6f1cc8b..67a4b06 100644
--- a/src/video/x11/SDL_x11opengl.c
+++ b/src/video/x11/SDL_x11opengl.c
@@ -210,36 +210,31 @@ 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 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;
diff --git a/src/video/x11/SDL_x11opengles.c b/src/video/x11/SDL_x11opengles.c
index 2d2054a..9818325 100644
--- a/src/video/x11/SDL_x11opengles.c
+++ b/src/video/x11/SDL_x11opengles.c
@@ -33,8 +33,8 @@ X11_GLES_LoadLibrary(_THIS, const char *path) {
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;
diff --git a/src/video/x11/SDL_x11window.c b/src/video/x11/SDL_x11window.c
index 6bc2eb9..a891528 100644
--- a/src/video/x11/SDL_x11window.c
+++ b/src/video/x11/SDL_x11window.c
@@ -366,10 +366,11 @@ X11_CreateWindow(_THIS, SDL_Window * window)
#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 @@ X11_CreateWindow(_THIS, SDL_Window * window)
vinfo = X11_GL_GetVisual(_this, display, screen);
#endif
}
+
if (!vinfo) {
return -1;
}
@@ -551,7 +553,9 @@ X11_CreateWindow(_THIS, SDL_Window * window)
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;