Reputation: 6145
I'm writing a really simple program using GLUT and C in XCode 4.2.
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH);
glutInitWindowSize(640, 480);
glutCreateWindow("GLUT Program");
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutIdleFunc(idle);
glutMainLoop();
return EXIT_SUCCESS;
}
When the window opens up, I can't close it via the red button in the top left corner (Mac) because it is grayed out. If any Java programming I've done is a model, there should be some function that sets the close operation so that the red exit button works. I also can't seem to find the documentation for the most recent version of GLUT. Whenever I google it I seem to get OpenGL documentation, which makes me a little more confused then I was on the relationship between the two (I thought GLUT was a cross-platform interface to interact with OpenGL).
Upvotes: 8
Views: 2797
Reputation: 8987
Add a handler for the close button and it will appear:
void winCloseFunc()
{
glutDestroyWindow(g_windowId);
exit(0);
}
int main( ... )
{
...
glutWMCloseFunc(winCloseFunc);
...
}
Upvotes: 0
Reputation: 93
well, i encountered this problem now, and i use
Command + Q
to quit the process, it works.
Upvotes: 1
Reputation: 21
Using the GLUT bindings for python on OS X, I find passing an event handler to glutWMCloseFunc is enough to give an action (apparently this is deprecated in favour of glutCloseFunc, but not with my version).
Upvotes: 2
Reputation: 26375
If you want to use the Mac's windowing system to write a native Mac-like application (and you should - your users will thank you!), you should be using NSOpenGLView instead of GLUT. There's some good sample code here.
Upvotes: 1