If the system time moves backward, the glut event loop will wait too long before triggering timer callbacks. It will wait until the system time catches up to what it was before and then some.
There are 2 possible solutions:
- Before sleeping in the main event loop, detect that the amount of time until the expiry if a timer is more than the originally scheduled delay. This approach is used by the glib event loop but it requires that the originally scheduled delay be stored in the timer object, which freeglut does not currently do.
- Use clock_gettime(CLOCK_MONOTONIC) instead of gettimeofday() to obtain the system time, because the former is guaranteed not to jump backward.
A patch is attached which implements the second solution, if it is available.
Log in to post a comment.