PDA

View Full Version : how to come out from glutMainLoop



jayaprakash
02-03-2009, 04:37 AM
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\n")
.
.
.
.
return 0;

ScottManDeath
02-09-2009, 10:44 AM
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.

-Ekh-
02-10-2009, 06:11 AM
if you don't use C++, there's still the at_exit functions, which are to my opinion, real good choices.