glutCloseFunc without terminating application

Hi,

I have created a window with glutCreateWindow and started a loop using glutMainLoop. I want to end that loop and close the window so I use glutLeaveMainLoop and glutCloseFunc to destroy it. Automatically, my application terminates.

I would like the application to persist after the window is destroyed. Is it possible? I’m using freeglut.

Thanks for your help.

glutCloseFunc() registers a callback function to be called when a window is closed. This needs to be done at startup, or at least before the user closes the window, otherwise closing the window will terminate the program. Your callback should call glutLeaveMainLoop().