Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Using own fixed timestep or setFramerateLimit?  (Read 1458 times)

0 Members and 1 Guest are viewing this topic.

arthur08

  • Newbie
  • *
  • Posts: 8
    • View Profile
Using own fixed timestep or setFramerateLimit?
« 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?

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Using own fixed timestep or setFramerateLimit?
« Reply #1 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.

Xornand

  • Jr. Member
  • **
  • Posts: 78
  • C++ / Python
    • View Profile
Re: Using own fixed timestep or setFramerateLimit?
« Reply #2 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.

arthur08

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Using own fixed timestep or setFramerateLimit?
« Reply #3 on: June 08, 2014, 10:34:08 am »
Ok i get it, those are two different things.
Thanks for the fast replies.

 

anything