src/video/SDL_video.c
changeset 7091 ff07fad908f8
parent 7089 257fc4e541e1
child 7107 2fcf7bf1d2b2
--- a/src/video/SDL_video.c	Mon Apr 22 18:15:00 2013 -0700
+++ b/src/video/SDL_video.c	Mon Apr 22 18:15:08 2013 -0700
@@ -2690,13 +2690,14 @@
 {
     int retval;
 
-    CHECK_WINDOW_MAGIC(window, -1);
-
-    if (!(window->flags & SDL_WINDOW_OPENGL)) {
-        return SDL_SetError("The specified window isn't an OpenGL window");
-    }
     if (!ctx) {
         window = NULL;
+    } else {
+        CHECK_WINDOW_MAGIC(window, -1);
+
+        if (!(window->flags & SDL_WINDOW_OPENGL)) {
+            return SDL_SetError("The specified window isn't an OpenGL window");
+        }
     }
 
     if ((window == _this->current_glwin) && (ctx == _this->current_glctx)) {
@@ -2758,7 +2759,11 @@
     if (!_this || !context) {
         return;
     }
-    _this->GL_MakeCurrent(_this, NULL, NULL);
+
+    if (_this->current_glctx == context) {
+        SDL_GL_MakeCurrent(NULL, NULL);
+    }
+
     _this->GL_DeleteContext(_this, context);
 }