0

Im using GLUT and i need to refresh a draw inside the idle function, my code is something like that:

void idle(){

     for(int i ;i<cant;i++){

          /* do some stuff*/

          glutPostRedisplay();
     }
}

inside the idle function proccess de data what i want to redraw in every itaration.

Someone can help me?

genpfault
  • 51,148
  • 11
  • 85
  • 139
Figa17
  • 781
  • 7
  • 20
  • 2
    http://stackoverflow.com/questions/6800512/how-to-update-glut-window-continuously - anyway, don't "block indefinitely" in idle and only post a redraw once at the end. The glut application is still single-threaded so the redraw won't be called until the idle function returns. It is a "post re-display after this function". – user2864740 Aug 20 '15 at 18:28
  • thank for your answer, i move the loop inside the display function and use de swapbuffer function to draw the image in every iteration. – Figa17 Aug 21 '15 at 03:25
  • Err, that's a similar problem - blocking one of 'stages' in the glut design. – user2864740 Aug 21 '15 at 04:01

1 Answers1

3

Do one (or few) things in idle, then postRedisplay. Let the timer (calling idle) do the loop !

you should ensure than the computation load of idle + redisplay is largely less than the timer rate you required (or the FPS you expect).

Fabrice NEYRET
  • 644
  • 4
  • 16