From ea9b11fa3596f8440aadb88ca8bfd1e5a2bae396 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Thu, 1 Aug 2013 00:01:57 -0400 Subject: [PATCH] Windows: Don't lose the existing current GL context in SDL_CreateWindow(). Fixes Bugzilla #1395. --- src/video/windows/SDL_windowswindow.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/video/windows/SDL_windowswindow.c b/src/video/windows/SDL_windowswindow.c index f40323ea6..c1ef463e6 100644 --- a/src/video/windows/SDL_windowswindow.c +++ b/src/video/windows/SDL_windowswindow.c @@ -231,10 +231,15 @@ WIN_CreateWindow(_THIS, SDL_Window * window) } #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;