X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Ffreeglut_main.c;h=64c788454f13c46ec58fd52ea6f65de81322cd95;hb=075a7a7ef67011d9f2c2ae939bc287fa97fc1b8f;hp=bdfe139be7882ca9d67ce9c4bbda95065a2dae4d;hpb=2433cf0a62aea70942f3645c6d4d90bd43d99691;p=freeglut diff --git a/src/freeglut_main.c b/src/freeglut_main.c index bdfe139..64c7884 100644 --- a/src/freeglut_main.c +++ b/src/freeglut_main.c @@ -265,7 +265,7 @@ static void fghcbCheckJoystickPolls( SFG_Window *window, SFG_Enumerator *enumera /* * Check if actually need to do the poll for the currently enumerated window: */ - if( window->State.JoystickLastPoll + window->State.JoystickPollRate >= checkTime ) + if( window->State.JoystickLastPoll + window->State.JoystickPollRate <= checkTime ) { /* * Yeah, that's it. Poll the joystick... @@ -399,67 +399,6 @@ void fgWarning( const char *fmt, ... ) va_end( ap ); } -/* - * Clean up on exit - */ -static void fgCleanUpGlutsMess( void ) -{ - int i; - - i = 0; - - if ( fgStructure.Windows.First != NULL ) - { - SFG_Window *win = (SFG_Window *)fgStructure.Windows.First ; - glEnd(); - glFinish(); - glFlush(); - while ( win != NULL ) - { - SFG_Window *temp_win = (SFG_Window *)win->Node.Next ; - fgDestroyWindow ( win, FALSE ) ; - win = temp_win ; - } - } - -#if 0 - /* these are pointers to external handles */ - - __glutWindowListSize = 0; - __glutStaleWindowList = NULL; - __glutWindowList = NULL; - __glutCurrentWindow = NULL; - - /* make sure we no longer have a GL context */ - - if ( wglGetCurrentContext() != NULL ) - { - wglDeleteContext( wglGetCurrentContext() ); - } - - hInstance = GetModuleHandle(NULL); - UnregisterClass( classname, hInstance ); - - /* clean up allocated timer memory */ - - tList = __glutTimerList; - i = 0; - - while ( __glutTimerList ) - { - i++; - tList = __glutTimerList; - - if ( __glutTimerList ) - __glutTimerList = __glutTimerList->next; - - if ( tList ) - free( tList ); - } -#endif -} - - /* -- INTERFACE FUNCTIONS -------------------------------------------------- */ /* @@ -1180,23 +1119,21 @@ void FGAPIENTRY glutMainLoop( void ) fgState.ExecState = GLUT_EXEC_STATE_STOP ; } + { + fgExecutionState execState = fgState.ActionOnWindowClose; - /* - * If we got here by the user closing a window or by the application closing down, there may still be windows open. - */ - fgCleanUpGlutsMess () ; - - /* - * Check whether we return to the calling program or simply exit - */ - if ( fgState.ActionOnWindowClose == GLUT_ACTION_EXIT ) - exit ( 0 ) ; + /* + * When this loop terminates, destroy the display, state and structure + * of a freeglut session, so that another glutInit() call can happen + */ + fgDeinitialize(); - /* - * When this loop terminates, destroy the display, state and structure - * of a freeglut session, so that another glutInit() call can happen - */ - fgDeinitialize(); + /* + * Check whether we return to the calling program or simply exit + */ + if ( execState == GLUT_ACTION_EXIT ) + exit ( 0 ) ; + } } /* @@ -1570,12 +1507,13 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPara /* Save the current window and menu and set the current window to the window whose menu this is */ SFG_Window *save_window = fgStructure.Window ; SFG_Menu *save_menu = fgStructure.Menu ; + SFG_Window *parent_window = window->ActiveMenu->ParentWindow ; fgSetWindow ( window ) ; fgStructure.Menu = window->ActiveMenu ; /* Execute the menu callback */ fgExecuteMenuCallback ( window->ActiveMenu ) ; - fgDeactivateMenu ( window->ActiveMenu->ParentWindow ) ; + fgDeactivateMenu ( parent_window ) ; /* Restore the current window and menu */ fgSetWindow ( save_window ) ;