How to detect a glut close window event?

Can someone tell me how to detect that a glut window is being closed so that i can process some commands before exiting. I have allocated memory dynamically to objects using new , which i want to deallocate before the program exits.


Take a look at this thread – I think it’s got what you’re looking for.