Windows: Don't lose the existing current GL context in SDL_CreateWindow().
authorRyan C. Gordon <icculus@icculus.org>
Thu, 01 Aug 2013 00:01:57 -0400
changeset 7556 574f465da18a
parent 7555 93b540e4db8a
child 7557 609bd82bdcf6
Windows: Don't lose the existing current GL context in SDL_CreateWindow(). Fixes Bugzilla #1395.
src/video/windows/SDL_windowswindow.c
--- a/src/video/windows/SDL_windowswindow.c	Wed Jul 31 16:25:50 2013 -0300
+++ b/src/video/windows/SDL_windowswindow.c	Thu Aug 01 00:01:57 2013 -0400
@@ -231,10 +231,15 @@
     }
 #if SDL_VIDEO_OPENGL_WGL
     if (window->flags & SDL_WINDOW_OPENGL) {
+        /* The current context is lost in SDL_GL_SetupWindow; recover it. */
+        SDL_Window *current_win = SDL_GL_GetCurrentWindow();
+        SDL_GLContext current_ctx = SDL_GL_GetCurrentContext();
         if (WIN_GL_SetupWindow(_this, window) < 0) {
             WIN_DestroyWindow(_this, window);
+            WIN_GL_MakeCurrent(_this, current_win, current_ctx);
             return -1;
         }
+        WIN_GL_MakeCurrent(_this, current_win, current_ctx);
     }
 #endif
     return 0;