Welcome, Guest. Please login or register.

Author Topic: Removed sf::Window::GetFrameTime()?  (Read 2619 times)

0 Members and 1 Guest are viewing this topic.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4986
  • Thor Developer
    • View Profile
    • Bromeon
Removed sf::Window::GetFrameTime()?
« on: January 21, 2012, 09:58:24 AM »
What has happened to GetFrameTime()? Do you prefer it time is measured on user side? It looks like sf::Window already uses a clock for SetFramerateLimit(), doesn't it?
Thor C++ Library: Particle systems, animations, dot products, event handlers and much more!
Learn SFML while developing a complete game in the book SFML Game Development!

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 28133
    • View Profile
    • SFML's website
    • Email
Removed sf::Window::GetFrameTime()?
« Reply #1 on: January 21, 2012, 10:35:34 AM »
It was removed because it was not as good as a user-side clock.

It was mainly used to get the elapsed time to pass to update functions, but:
- the returned time was wrong (last frame duration instead of time elapsed since last update)
- there's no reason for such a function to be in the sf::Window class

The new way of measuring the update time is 100% accurate (also thanks to the new sf::Clock::Restart function):
Code: [Select]
sf::Clock clock;
...
Update(clock.Restart());


The other use of this function was to compute FPS, but I don't consider that it deserves a dedicated function in the public API.
Laurent Gomila - SFML developer

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4986
  • Thor Developer
    • View Profile
    • Bromeon
Removed sf::Window::GetFrameTime()?
« Reply #2 on: January 21, 2012, 11:02:11 AM »
Okay, then I am going to use sf::Clock directly in the future. Thanks for the explanation!
Thor C++ Library: Particle systems, animations, dot products, event handlers and much more!
Learn SFML while developing a complete game in the book SFML Game Development!