Wednesday 23 July 2008

Leaving glutMainLoop without killing the application

I am working with OpenGL since a few months ago and enjoying it a lot. I was using glut to create my interfaces but it sometimes is quite limited.

A few days ago I was trying to stop and restart the glut main loop. After thinking and searching a lot, I found the function
void glutLeaveMainLoop(void)

It is available in freeglut, but not in glut. I wanted it to just leave the main loop, but its default behavior is... it does not just leave the main loop, it closes the application too.

To function as I expected, I must, after calling glutInit, call
glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS);

I could not find it documented anywhere, so, here it is... Thanks for reading.

1 comment:

Pedro Góes said...

I just can't find this function on the header... But it is available on the .c implementation. I'm using glut 2.6.0. Do you know why they haven't added the prototype to the header?