Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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++?

like image 524
user3882772 Avatar asked Dec 07 '25 10:12

user3882772


1 Answers

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());
like image 103
Devank Avatar answered Dec 09 '25 23:12

Devank



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!