* Group all GLUT exit cleanup tasks in one place, __glutExitCleanup().
* Automatically leave game mode if it's still active at exit * Remove explicit game mode cleanup from testbed app. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37822 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
6e55a1104a
commit
24ca4df9de
|
@ -168,7 +168,7 @@ void glutInit(int *argcp, char **argv) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
__glutInit(); /* Create BApplication first so DisplayWidth() works */
|
||||
if (geometry) {
|
||||
int flags, x, y, width, height;
|
||||
|
@ -225,14 +225,25 @@ void __glutInit() {
|
|||
bigtime_t unused;
|
||||
__glutInitTime(&unused);
|
||||
|
||||
/* set atexit() function to destroy all windows before exiting */
|
||||
if(atexit(__glutDestroyAllWindows))
|
||||
/* set atexit() function to cleanup before exiting */
|
||||
if(atexit(__glutExitCleanup))
|
||||
__glutFatalError("can't set exit handler");
|
||||
|
||||
|
||||
/* similarly, destroy all windows on CTRL-C */
|
||||
signal(SIGINT, sigHandler);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
__glutExitCleanup()
|
||||
{
|
||||
if (glutGameModeGet(GLUT_GAME_MODE_ACTIVE) > 0)
|
||||
// Try to restore initial screen mode...
|
||||
glutLeaveGameMode();
|
||||
|
||||
__glutDestroyAllWindows();
|
||||
}
|
||||
|
||||
/***********************************************************
|
||||
* FUNCTION: glutInitWindowPosition (2.2)
|
||||
*
|
||||
|
|
|
@ -790,6 +790,7 @@ extern HDC XHDC;
|
|||
/* private routines from glutInit.cpp */
|
||||
void __glutInitTime(bigtime_t *beginning);
|
||||
void __glutInit();
|
||||
void __glutExitCleanup();
|
||||
|
||||
/* private routines from glutMenu.cpp */
|
||||
class GlutMenu; // avoid including glutMenu.h
|
||||
|
|
|
@ -157,14 +157,9 @@ init(void)
|
|||
|
||||
|
||||
void
|
||||
clean_exit(void)
|
||||
on_exit(void)
|
||||
{
|
||||
printf("Exit.\n");
|
||||
|
||||
if (glutGameModeGet(GLUT_GAME_MODE_ACTIVE)) {
|
||||
printf("glutLeaveGameMode()\n");
|
||||
glutLeaveGameMode();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -226,7 +221,7 @@ main(int argc, char **argv)
|
|||
|
||||
init();
|
||||
|
||||
atexit(clean_exit);
|
||||
atexit(on_exit);
|
||||
glutMainLoop();
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Reference in New Issue