PDA

View Full Version : Problem with glutIdleFunc



Mighty
04-20-2004, 08:51 AM
I call glutIdleFunc(NULL) in a separate function which control the position of the game objects. GlutIdleFunc originally pointed glutDisplay. I then moved a couple objects in my game, then I tried to explicitly call glutDisplay() in the same function to see the update to the game state, but nothing is redrawn... anyone know why?

mikael_aronsson
04-21-2004, 04:09 AM
Hi !

I assume glutDisplay() is your own function that you use as a callback... ?

It is important to understand that you cannot use any opengl calls unless you have setup a rendering context, this is done bu glut for you so you do not need to bother, but this is only done when glut executes the callback functions you have setup, if you try to call glutDisplay() from any other place in your code you may not have a rendering context active and nothing happens.

What you should do is to call glutPostReDisplay() (not sure if the name is correct...) this function call tell glut to call your rendering callback as soon as possible (but it will not happen until you return from the idle function).

Mikael