PDA

View Full Version : glutCloseFunc without terminating application



Finfa811
04-14-2016, 03:20 AM
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.

GClements
04-14-2016, 03:24 AM
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.

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().