7

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).

Adam
  • 865
  • 10
  • 24
Eric Thoma
  • 5,045
  • 6
  • 26
  • 39
  • Which GLUT implementation are you using? – genpfault Jan 03 '12 at 22:04
  • I honestly don't know. As I understand, that stuff is included in the distributions of XCode and OpenGL is in the System Updates. So I am using whatever is packaged in with XCode 4.2 and Lion. – Eric Thoma Jan 03 '12 at 22:52

4 Answers4

3

On Mac OS, the window cannot be closed and the application has to be quit instead (sources here).

F'x
  • 11,555
  • 6
  • 67
  • 120
2

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).

pec27
  • 21
  • 1
2

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.

user1118321
  • 23,821
  • 4
  • 52
  • 78
1

well, i encountered this problem now, and i use

Command + Q

to quit the process, it works.

Hualin
  • 63
  • 6