X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Ffreeglut_main.c;h=7984f58a5a43f4925aed07ce050435e61d105817;hb=bffa189dd239efb45ec53bd69684226d0b1b0ee2;hp=1c11f0d30801079b6250992b6fe770684b6414df;hpb=646676b8dbf8ab504ac8a275fe9a63a403a3190b;p=freeglut diff --git a/src/freeglut_main.c b/src/freeglut_main.c index 1c11f0d..7984f58 100644 --- a/src/freeglut_main.c +++ b/src/freeglut_main.c @@ -1175,9 +1175,12 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPara fgSetupPixelFormat( window, FALSE, PFD_MAIN_PLANE ); /* - * Create the OpenGL rendering context now + * Create or get the OpenGL rendering context now */ - window->Window.Context = wglCreateContext( window->Window.Device ); + if ( fgState.UseCurrentContext == TRUE ) + window->Window.Context = wglGetCurrentContext(); + else + window->Window.Context = wglCreateContext( window->Window.Device ); /* * Still, we'll be needing to explicitly resize the window @@ -1287,8 +1290,20 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPara */ if( fgStructure.Window == window ) { + int used = FALSE ; + SFG_Window *iter ; + wglMakeCurrent( NULL, NULL ); - wglDeleteContext( window->Window.Context ); + /* Step through the list of windows. If the rendering context is notbeing used + * by another window, then we delete it. + */ + for ( iter = fgStructure.Windows.First; iter; iter = iter->Node.Next ) + { + if ( ( iter->Window.Context == window->Window.Context ) && ( iter != window ) ) + used = TRUE ; + } + + if ( used == FALSE ) wglDeleteContext( window->Window.Context ); } /*