GLUT - On exit code

Where do we put code we want to run when the app exits ? glutMainLoop( ) never returns so we can’t put it after. I’ve checked the Callback funtions, the states, etc. But didn’t find anything.

To my knowledge, there isn’t a way to execute code after glutMainLoop. There aren’t callbacks, either.

Definitely a disadvantage of using GLUT.

The ANSI C atexit() function can be used to set a callback if you’re quitting with exit(). Not sure if it’s respected by Win32 (e.g. whether it’s called when you close a GLUT window by clicking the close box in the menubar) but you could give it a try.

The atexit() function worked fine ! It even detects the close window icon ! Thanks for the help !!!