View Full Version : different frame rates
11-11-2003, 01:59 PM
How do games run the same speed independently of the frame rate?
11-11-2003, 02:09 PM
consistent rate of motion can be maintained by keeping a running timer, and then updating the player's position, animations, etc, by an amount relative to the time that has passed. for example, if you want a player to move 20 units per second, and you're getting 200 fps, you move the player 0.1 unit each frame, whereas you would shift the player's position 1 unit each frame if they were getting 20 fps or you would shift them 20 units each frame if they were getting 1 fps. so at the beginning of each frame, just check how much time has passed since the last frame, and use that to adjust how far everything should have progressed.
11-11-2003, 04:33 PM
Please leave questions about physics, collision, entity management, installers, etc for the appropriate forums. Which, for this question, might include:
www.gamedev.net (http://www.gamedev.net) www.flipcode.com (http://www.flipcode.com)
the gd-algorithms mailing list
Well, Jwatte i think this topic is not so far related to opengl. ;)
Let's say that u want that you're prg has to be synced within the retrace period.
First of all, u have to check for the current video mode refresh rate (Hz), note that it could be evaluated/calculated but most of the time it is enumerated into the video modes lists.
Once you got the resfresh rate, you can then check for the number of missed frames (with a timer..) which means when the framerate is below 60FPS for a 60Hz period for instance.
Then, the number of missed frames will be used to re-run your game management (behaviors,physic, collisions and so on & so forth).
Note that the display must be effective only once and has to be skipped when frames are skipped.
That's it, for many synchronisation purposes with OpenGL i use the great OpenGL framework GLFW from Marcus Geelnard! (http://glfw.sourceforge.net/) and we are using this synchronisation system for our upcoming game (http://www.orkysquad.org), it works nicely without any ugly tiring due to async management. ;)
11-12-2003, 01:34 AM
I am solving this problem by running two different threads which own separate timers. One thread moves the objects according in realtime and another renders them. You get the same animation speed on different machines with different framerates. I guess it's the most simplest way.
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.