PDA

View Full Version : In example 1.3 of Redbook i have a question



Kilopopo
04-29-2010, 02:15 AM
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: http://www.glprogramming.com/red/chapter01.html

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

thanks
Kilopopo

ZbuffeR
04-29-2010, 04:11 AM
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 :
http://www.opengl.org/resources/libraries/glut/spec3/node63.html

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 :
http://www.opengl.org/resources/libraries/glut/spec3/node20.html

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