How to come out from glutMainLoop

Hi all,

I am trying to use gluLeaveMainLoop() to come out from glutMainLoop(). But it is not comming, can anybody suggest how to use glutLeaveMainLoop().
My requrement is i need execute some code below the glutMainLoop();
for example:

glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
glutInitWindowSize(width,height);
glutInitWindowPosition(100,100);
getwin = glutCreateWindow(argv[0]);

glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE,
GLUT_ACTION_GLUTMAINLOOP_RETURNS);

init();

glutDisplayFunc(display);
glutIdleFunc(startDisplay);

glutMainLoop();
printf("came out from glutMainLoop
")
.
.
.
.
return 0;

You wrap your call to glutMainLoop in a try catch block and then, when you want to leave the loop, you throw an exception of some [custom] type, which then will be caught in the main function, giving you the chance to do stuff.

if you don’t use C++, there’s still the at_exit functions, which are to my opinion, real good choices.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.