user3882772
user3882772

Reputation: 149

SFML 2.1 get frame time

What is the equivalent of window.GetFrameTime in SFML 2.1?
I think it's from SFML 1.6 or SFML 2.0.
How can I use it in SFMl 2.1 on c++?

Upvotes: 3

Views: 3021

Answers (1)

Devank
Devank

Reputation: 56

GetFrameTime() was removed from SFML at the beginning of 2012. The reasoning for it can be found here: http://en.sfml-dev.org/forums/index.php?topic=6831.0

Users have to create an sf::Clock object now and keep time themselves. This has more advantages than disadvantages including:

  • Correct time reporting (GetFrameTime() reported the time spent during the last frame)
  • More control over between which points in your code the time is to be measured
  • More control over the precision required

The new way of measuring the update time is 100% accurate (also thanks to the new sf::Clock::Restart function)

Code:

sf::Clock clock;
...
Update(clock.Restart());

Upvotes: 3

Related Questions