View Full Version : Too fast animation
02-06-2003, 12:33 PM
I guess this is a really stupid question for you guys who have been into opengl for some while.. but here i go:
For example, i made i spinning cube, but it spins too fast!, how can i regulate the speed of the things that are rendered? so that nomatter what computer i run it on, will "play" at the same speed?
02-06-2003, 12:40 PM
Hehe, you can ignore my stupid question, seems that when i was using my riva tnt2 card, i had to set a high angle in glRotatef(); i just set the angle down, and the animation went at the speed i wanted http://www.opengl.org/discussion_boards/ubb/smile.gif
02-06-2003, 12:43 PM
You should use a timer. Either call the rendering function every x milliseconds or every time the rendering is called determine the time since the last call and base your new frame on the elapsed time.
02-06-2003, 02:50 PM
shinpaughp is right.
Your method is called frame-based animation. It means that the animation is done on each frame without taking into account the elapsed time between these frames. So ok, now you reduce your rotation angle, and the cube spins slower. But what about next gen cards. As they will outperform current cards, the cube will spin too fast again. And what about older cards? Even at a respectable 25fps (ok for a spinning cube it's a bit low...), your cube will take ages to spin around itself.
You should implement a time-based animation method, that is calculate the new object position according to the elapsed time since last frame was drawn. In your case, define an angular velocity and calculate the rotation angle for each frame given the angular velocity and the elapsed time since last frame was drawn.
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.