I have an animation started with glutTimerFunc. I want it to last for 5 seconds and stop. How would I do that?
mike
I have an animation started with glutTimerFunc. I want it to last for 5 seconds and stop. How would I do that?
mike
If you look at the function signature
glutTimerFunc(unsigned int timeout, void( *callback )( int data ), int data);
you have a minimal waiting time until your callback is called once. To coarsely approximate the time you already spent doing the animation you can simply calculate
timeSpent = timeout * invocations
and as soon as timeSpent >= 5000 you don’t call glutTimerFunc anymore.