How to kill processes before closing the window (using GLUT)

I have the class X. I want to destruct it when user click [_] [x]-here :slight_smile: (close window button). What should I do? I need it, because I mmap something in class X and I need to munmap it while exit.


X *myclass;

int main(int argc, char** argv) {
myclass = new X();

// Some glut stuff..


return 1;


How to delete myclass or destruct it (myclass->~X) while exit? Where?


I use GLUT thread and create new window with GLUT too. TNX!

With FreeGLUT you can choose to run stuff before the app exits, and I think when a window is closed. With standard GLUT, you have to use atexit() to register a callback which will get called as the app is shutting down.

Thank you very much! I’ve used FreeGLUT glutCloseFunc() :cool:

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.