SFML community forums

Help => General => Topic started by: arthur08 on June 07, 2014, 06:59:21 pm

Title: Using own fixed timestep or setFramerateLimit?
Post by: arthur08 on June 07, 2014, 06:59:21 pm
I want to use a fixed timestep in my game and i read a few articles about it but i don't really understand it. Is the setFramerateLimit as good as your own fixed timestep and if not can someone help me with the fixed timestep?
Title: Re: Using own fixed timestep or setFramerateLimit?
Post by: Jesper Juhl on June 07, 2014, 07:04:37 pm
A fixed timestep and setFramerateLimit are two different things.

Try searching the forum - there's been lots of posts on this.
Title: Re: Using own fixed timestep or setFramerateLimit?
Post by: Xornand on June 08, 2014, 04:44:22 am
setFramerateLimit() affects your Window instance in order to synchronize it with the requested framerate. If you include the window with other subsystems on the same thread, then it will appear as a form of a "fixed time-step" function - however that's only because everything is on the same thread. Also, keep in mind that the time intervals are likely not to be consisted.

One of the ways to solve it is to measure the delta of time between the moment the game loop starts iteration and ends updating the subsystems. You can then place an actual sleeping function at the end of the game loop, which will check whether the delta is smaller than the fixed time-step you wish to have - if it is, the function should only sleep for the remainder of the time required to "catch-up" with your time-step.
Title: Re: Using own fixed timestep or setFramerateLimit?
Post by: arthur08 on June 08, 2014, 10:34:08 am
Ok i get it, those are two different things.
Thanks for the fast replies.