X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Ffreeglut_window.c;h=743b94ff6f1049701be526cf58c165a37167caaf;hb=e914664550e34587f4b10d3fe52c61fbe6d61771;hp=99f871f016d17b6488476ce0202e3f93a9ebb6d5;hpb=98ea79ef777bea593a87aef9600ee3d4fda6e110;p=freeglut diff --git a/src/freeglut_window.c b/src/freeglut_window.c index 99f871f..743b94f 100644 --- a/src/freeglut_window.c +++ b/src/freeglut_window.c @@ -554,13 +554,34 @@ void fgCloseWindow( SFG_Window* window ) #elif TARGET_HOST_WIN32 - SendMessage( - window->Window.Handle, - WM_CLOSE, - 0, - 0 - ); + /* + * Make sure we don't close a window with current context active + */ + if( fgStructure.Window == window ) + wglMakeCurrent( NULL, NULL ); + + /* + * Step through the list of windows. If the rendering context + * is not being used by another window, then we delete it. + */ + { + int used = FALSE ; + SFG_Window *iter ; + + for( iter = (SFG_Window *)fgStructure.Windows.First; + iter; + iter = (SFG_Window *)iter->Node.Next ) + { + if( ( iter->Window.Context == window->Window.Context ) && + ( iter != window ) ) + used = TRUE; + } + + if( ! used ) + wglDeleteContext( window->Window.Context ); + } + DestroyWindow( window->Window.Handle ); #endif } @@ -589,6 +610,7 @@ int FGAPIENTRY glutCreateSubWindow( int parentID, int x, int y, int w, int h ) parent = fgWindowByID( parentID ); freeglut_return_val_if_fail( parent != NULL, 0 ); window = fgCreateWindow( parent, "", x, y, w, h, GL_FALSE, GL_FALSE ); + window->State.OldHeight = window->State.OldWidth = -1; return window->ID; } @@ -601,7 +623,7 @@ void FGAPIENTRY glutDestroyWindow( int windowID ) freeglut_return_if_fail( window != NULL ); { fgExecutionState ExecState = fgState.ExecState; - fgAddToWindowDestroyList( window, GL_TRUE ); + fgAddToWindowDestroyList( window ); fgState.ExecState = ExecState; } }