What is the nicest way to close FreeGLUT?

Deadly 提交于 2019-11-30 12:17:32

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"

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
}
malin

Try this method:

glutDestroyWindow(glutGetWindow());
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!