View Full Version : Displaying in a loop--arrrrr...
03-03-2003, 07:17 PM
I am trying desparately to make a program that'll draw an ellipse with GL_POINTS, but for some reason, the while loop that contains the glutIdleFunc only processes the function the last time through the loop. The while loop runs 6 times, but only transfers control to my display function on the sixth time. What am I doing wrong? (I have also tried glutPostRedisplay) Thanks so much.
03-03-2003, 08:43 PM
The function you pass to glutIdleFunc basically is used when the code is idle (ie no pending events). So, you typically only call glutIdleFunc once in your main function to tell GLUT to use that function when idle. Then, whenever the program is idle it will use your idleFunc. Or use display func and reshape func. You can also handle keyboard and mouse events. Depends on what you are trying to achieve.
So, do not call glutIdleFunc multiple times in a loop, unless you actually want it to switch between different functions while idling, but that would best be done through glutTimerFunc to allow it time to actually use the various functions if that were your intention.
glutSwapBuffers();//if using GLUT_DOUBLE
int main(int argc, char** argv)
init();//initialize clear color, enable depth test, etc
The idlefunc will be called continuously while there are no pending events, such as keyboard, mouse, etc if defined. There is no need to try to stay within the idlefunc and maintain the loop indefinitely. It will continue to be called whenever idle occurs.
Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.