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
*/
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 );
}
/*