I\'m really having trouble closing my console application with FreeGLUT.
I would like to know what the best way is to take every possible closing, because I don\'t w
Try this method:
glutDestroyWindow(glutGetWindow());
I use glutDestroyWindow(int handle);
or
According to ID: RigidBody at OpenGL forum
void destroy_window()
{
window_valid = -1;
}
void display_func()
{
if(window_valid == -1)
return;
// draw things
}
I use this function:
void glutLeaveMainLoop ( void );
There is more information on their sourceforge page but I never used that functionality:
The glutLeaveMainLoop function causes freeglut to stop the event loop. If the GLUT_ACTION_ON_WINDOW_CLOSE option has been set to GLUT_ACTION_CONTINUE_EXECUTION, control will return to the function which called glutMainLoop; otherwise the application will exit.
http://freeglut.sourceforge.net/docs/api.php#EventProcessing
It is safe to use delete
on a null pointer, no need to check.
Thanks to Maarten's post, this works to me:
glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE,GLUT_ACTION_CONTINUE_EXECUTION);
whenever you want to leave the mainloop without termiante the application use:
glutLeaveMainLoop();
don't forget to include "freeglut.h"