Sunday, May 25, 2014

GLUT's display func called only once

Suppose you have the following code in your main:

void Update(void){_tsp.update();}
void Display(void){_tsp.DrawCities();}
// your other code here
int main(int argc, char * argv[])
{
...
..
// your other code here
...

glutDisplayFunc(Display);  // callback for draw function
glutIdleFunc(Update);  //callbak for update function

You observe that the Display called only once and Update on all loops.
If you want both Display and Update be called, add

glutPostRedisplay(); 

In yor Update function at the end. This will trigger callback for the display-function.

No comments:

Post a Comment