More OpenGL ES fixes from Scott Percival
authorSam Lantinga <slouken@libsdl.org>
Thu, 19 Jul 2012 09:36:58 -0700
changeset 6373 494e0436525f
parent 6372 76d0f2cf2ca6
child 6374 d4ed97e63c22
More OpenGL ES fixes from Scott Percival
src/video/x11/SDL_x11opengl.c
src/video/x11/SDL_x11opengles.c
src/video/x11/SDL_x11window.c
--- a/src/video/x11/SDL_x11opengl.c	Wed Jul 18 15:53:33 2012 -0700
+++ b/src/video/x11/SDL_x11opengl.c	Thu Jul 19 09:36:58 2012 -0700
@@ -128,9 +128,9 @@
         return -1;
     }
 
-#if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
     /* 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;
@@ -141,8 +141,11 @@
         _this->GL_SwapWindow = X11_GLES_SwapWindow;
         _this->GL_DeleteContext = X11_GLES_DeleteContext;
         return X11_GLES_LoadLibrary(_this, path);
+#else
+        SDL_SetError("SDL not configured with OpenGL ES/EGL support");
+        return -1;
+#endif
     }
-#endif
 
 
     /* Load the OpenGL library */
--- a/src/video/x11/SDL_x11opengles.c	Wed Jul 18 15:53:33 2012 -0700
+++ b/src/video/x11/SDL_x11opengles.c	Thu Jul 19 09:36:58 2012 -0700
@@ -99,9 +99,9 @@
         return -1;
     }
 
-#if SDL_VIDEO_OPENGL_GLX
     /* If SDL_GL_CONTEXT_EGL has been changed to 0, switch over to X11_GL functions  */
     if (_this->gl_config.use_egl == 0) {
+#if SDL_VIDEO_OPENGL_GLX
         _this->GL_LoadLibrary = X11_GL_LoadLibrary;
         _this->GL_GetProcAddress = X11_GL_GetProcAddress;
         _this->GL_UnloadLibrary = X11_GL_UnloadLibrary;
@@ -112,8 +112,11 @@
         _this->GL_SwapWindow = X11_GL_SwapWindow;
         _this->GL_DeleteContext = X11_GL_DeleteContext;
         return X11_GL_LoadLibrary(_this, path);
+#else
+        SDL_SetError("SDL not configured with OpenGL/GLX support");
+        return -1;
+#endif
     }
-#endif
 
 #ifdef RTLD_GLOBAL
     dlopen_flags = RTLD_LAZY | RTLD_GLOBAL;
--- a/src/video/x11/SDL_x11window.c	Wed Jul 18 15:53:33 2012 -0700
+++ b/src/video/x11/SDL_x11window.c	Thu Jul 19 09:36:58 2012 -0700
@@ -391,7 +391,12 @@
         return -1;
     }
 #if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
-    if (window->flags & SDL_WINDOW_OPENGL) {
+    if ((window->flags & SDL_WINDOW_OPENGL) && (_this->gl_config.use_egl == 1)) {
+        if (!_this->gles_data) {
+            XDestroyWindow(display, w);
+            return -1;
+        }
+
         /* Create the GLES window surface */
         _this->gles_data->egl_surface =
             _this->gles_data->eglCreateWindowSurface(_this->gles_data->
@@ -401,6 +406,7 @@
 
         if (_this->gles_data->egl_surface == EGL_NO_SURFACE) {
             SDL_SetError("Could not create GLES window surface");
+            XDestroyWindow(display, w);
             return -1;
         }
     }