Move the fix for Bugzilla #1395 into WIN_GL_SetupWindow() directly.
authorRyan C. Gordon <icculus@icculus.org>
Thu, 01 Aug 2013 00:27:22 -0400
changeset 75590dd3b05797f9
parent 7558 0614504d2265
child 7560 1d6717a8b256
Move the fix for Bugzilla #1395 into WIN_GL_SetupWindow() directly.

It's a cleaner solution.
src/video/windows/SDL_windowsopengl.c
src/video/windows/SDL_windowswindow.c
     1.1 --- a/src/video/windows/SDL_windowsopengl.c	Wed Jul 31 21:22:09 2013 -0700
     1.2 +++ b/src/video/windows/SDL_windowsopengl.c	Thu Aug 01 00:27:22 2013 -0400
     1.3 @@ -418,8 +418,9 @@
     1.4      return pixel_format;
     1.5  }
     1.6  
     1.7 -int
     1.8 -WIN_GL_SetupWindow(_THIS, SDL_Window * window)
     1.9 +/* actual work of WIN_GL_SetupWindow() happens here. */
    1.10 +static int
    1.11 +WIN_GL_SetupWindowInternal(_THIS, SDL_Window * window)
    1.12  {
    1.13      HDC hdc = ((SDL_WindowData *) window->driverdata)->hdc;
    1.14      PIXELFORMATDESCRIPTOR pfd;
    1.15 @@ -529,6 +530,17 @@
    1.16      return 0;
    1.17  }
    1.18  
    1.19 +int
    1.20 +WIN_GL_SetupWindow(_THIS, SDL_Window * window)
    1.21 +{
    1.22 +    /* The current context is lost in here; save it and reset it. */
    1.23 +    SDL_Window *current_win = SDL_GL_GetCurrentWindow();
    1.24 +    SDL_GLContext current_ctx = SDL_GL_GetCurrentContext();
    1.25 +    const int retval = WIN_GL_SetupWindowInternal(_this, window);
    1.26 +    WIN_GL_MakeCurrent(_this, current_win, current_ctx);
    1.27 +    return retval;
    1.28 +}
    1.29 +
    1.30  SDL_GLContext
    1.31  WIN_GL_CreateContext(_THIS, SDL_Window * window)
    1.32  {
     2.1 --- a/src/video/windows/SDL_windowswindow.c	Wed Jul 31 21:22:09 2013 -0700
     2.2 +++ b/src/video/windows/SDL_windowswindow.c	Thu Aug 01 00:27:22 2013 -0400
     2.3 @@ -231,15 +231,10 @@
     2.4      }
     2.5  #if SDL_VIDEO_OPENGL_WGL
     2.6      if (window->flags & SDL_WINDOW_OPENGL) {
     2.7 -        /* The current context is lost in SDL_GL_SetupWindow; recover it. */
     2.8 -        SDL_Window *current_win = SDL_GL_GetCurrentWindow();
     2.9 -        SDL_GLContext current_ctx = SDL_GL_GetCurrentContext();
    2.10          if (WIN_GL_SetupWindow(_this, window) < 0) {
    2.11              WIN_DestroyWindow(_this, window);
    2.12 -            WIN_GL_MakeCurrent(_this, current_win, current_ctx);
    2.13              return -1;
    2.14          }
    2.15 -        WIN_GL_MakeCurrent(_this, current_win, current_ctx);
    2.16      }
    2.17  #endif
    2.18      return 0;