Hello Everybody!
I just got a pretty simple question (prehaps).
How can i limit the framerate to 60 (or any other number)?
Thanks!
Set FPS to ...?
Set FPS to ...?
"Clicker"
If you can, you shouldn't limit your framerate. If you need to limit it to cap movement speeds, etc, then base them on time you'll be okay. Otherwise if VSync doesn't give you the results you want it'll be some really tedius coding... basically in your main loop you'll have to get the time, and see if .016 seconds have passed since your last frame; then decide to draw it based on that.
Hmm okay if you want to use VSync then just set VSync to true when you create your device.
If you want to base your movement on time then at the end of every frame use getTime() and store it. Then when your character goes to move get the current time, do some math with the time you got, and came up with a movement distance. So if you do something like setPosition(vector3df(getPosition.X(), getPosition.Y(), currentTime - previousTime)) you'll end up with the node moving a distance equal to the milliseconds passed since the last frame was drawn.
If you want to limit your framerate to about 60 FPS get the time each time you draw your frame, and when you draw the next check if .016 of a second has passed, and only draw and grab the time if it has.
If you want to base your movement on time then at the end of every frame use getTime() and store it. Then when your character goes to move get the current time, do some math with the time you got, and came up with a movement distance. So if you do something like setPosition(vector3df(getPosition.X(), getPosition.Y(), currentTime - previousTime)) you'll end up with the node moving a distance equal to the milliseconds passed since the last frame was drawn.
If you want to limit your framerate to about 60 FPS get the time each time you draw your frame, and when you draw the next check if .016 of a second has passed, and only draw and grab the time if it has.
Lol people are usually trying to increase there Frame Rate Per Second not limit it..
Programming Blog: http://www.uberwolf.com
-
- Posts: 277
- Joined: Thu Dec 15, 2005 6:11 pm
You know that is the truth!!dejai wrote:Lol people are usually trying to increase there Frame Rate Per Second not limit it..
But yeah, you need to make your movement/physics based on actual time passed as explained above. You movement won't depend on the FPS, so like if your game skips a beat due to another program or whatever, the movement will "skip" but be where it is supposed to be according to the time passed.