After looking at a lot of code I see many people handle scene updates in GLUT differently. It usually invoves either glutPostRedisplay() or glutIdleFunc(). Just wondering which is more optimal, or is there a better way? I’m using VC++ and GLUT and making simple Dos executables.
Example 1: *****************************
void display()
{
//update your objects and draw them
glutSwapBuffers();
glutPostRedisplay();
}
void main()
{
// do initialization here etc…
glutDisplayFunc(display);
}
or Example 2: *****************************
void display()
{
//update objects and draw scene
glutSwapBuffers();
}
Remember some examples are just examples just to show how a function work, maybe not the best aproach.
I think you have to look at what your end program is going to be doing, if you just want to spin a cube that really does not make too much diffrence how you do it. But then you get to a advanced program then you do have to look at each section and timming becomes important.
Both of you examples are so close I don’t think that it would make much diffrence.
I like to break thing down into sections, which in a large program will come in handy when trying to get the bugs out.