In example 1.3 of Redbook i have a question

I am just wondering how the spindisplay spins the display by putting glutpostredisplay and glutIdleFunc in the mouse function which is used as a parameter with glutMouseFunc(mouse)?

the whole code is at the buttom of this link:

im an intermediate level programmer in c i have not programmed in opengl at all but i am interested and eager to learn.

The new stuff to me that blows me away is a function that has a parameter as a function.

but in this case i just want to know how spindisplay works with all the glCalls

I hope anyone here can Help


glutIdleFunc sets a function to be called when glut main loop finds no event in the event queue, so it gets called almost continuously. When set to NULL, it is disabled :

glutPostRedisplay adds a “please redisplay” event in the glut event queue, and when glut main loop will find this event, it will call the function defined with glutDisplayFunc :

(not much to do with actual OpenGL programming, this is more generic event-driven programming)