X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;ds=sidebyside;f=src%2Ffreeglut_window.c;h=743b94ff6f1049701be526cf58c165a37167caaf;hb=e914664550e34587f4b10d3fe52c61fbe6d61771;hp=f268eb33bc7b88ae10435752fc3f6ac5eb1104e7;hpb=8f96cc73e71a8e4f2acb579c29132c16358191f0;p=freeglut diff --git a/src/freeglut_window.c b/src/freeglut_window.c index f268eb3..743b94f 100644 --- a/src/freeglut_window.c +++ b/src/freeglut_window.c @@ -529,12 +529,12 @@ void fgOpenWindow( SFG_Window* window, const char* title, #endif window->Window.DoubleBuffered = - ( fgState.DisplayMode & GLUT_DOUBLE ) ? 1 : 0 ; + ( fgState.DisplayMode & GLUT_DOUBLE ) ? 1 : 0; if ( ! window->Window.DoubleBuffered ) { - glDrawBuffer ( GL_FRONT ) ; - glReadBuffer ( GL_FRONT ) ; + glDrawBuffer ( GL_FRONT ); + glReadBuffer ( GL_FRONT ); } fgSetWindow( window ); } @@ -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; } } @@ -625,7 +647,7 @@ void FGAPIENTRY glutSetWindow( int ID ) return; } - fgSetWindow( window ) ; + fgSetWindow( window ); } /*