SFML community forums

Help => Window => Topic started by: Zhiren on June 14, 2014, 10:20:41 am

Title: Question about setFrameRateLimit
Post by: Zhiren on June 14, 2014, 10:20:41 am
I am writing a game and set the frame rate limit to 60 FPS.  However the frames actually run at about 30 FPS.  So I just am curious why that is. If I set the Vsync on and turn off the limit, it runs at 60. Would this change from computer to computer with different refresh rates?  Also, I probably shouldn't be putting timed events based on a frame count should I?  I probably should use the built in Time functions, right?
Title: Re: Question about setFrameRateLimit
Post by: Ixrec on June 14, 2014, 10:38:49 am
Quote
Would this change from computer to computer with different refresh rates?
Yes.  Also different processor speeds and OS scheduling behavior.

Quote
Also, I probably shouldn't be putting timed events based on a frame count should I?  I probably should use the built in Time functions, right?
Yes.  A frame is not a unit of time.
Title: Re: Question about setFrameRateLimit
Post by: Nexus on June 14, 2014, 11:17:19 am
Game logic should not depend on the actual time passed in a frame, otherwise you get non-deterministic and non-reproducible behavior. The typical approach is to let the logic run at a constant rate independent of the frame rate, and adapt the graphics dynamically. Fix your timestep (http://gafferongames.com/game-physics/fix-your-timestep/) is a more sophisticated article on that topic, there have also been several forum discussions in the past.