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

Author Topic: How to calculate FPS in SFML 2.0?  (Read 3679 times)

0 Members and 1 Guest are viewing this topic.

Chunker120

  • Newbie
  • *
  • Posts: 31
    • View Profile
How to calculate FPS in SFML 2.0?
« on: October 07, 2012, 03:21:47 pm »
This is a question that's been bugging me for ages. When I try to measure time I get weird numbers such as 12e10 or something similar.

Can anyone explain how FPS is calculated in SFML 2.0?

MorleyDev

  • Full Member
  • ***
  • Posts: 219
  • "It is not enough for code to work."
    • View Profile
    • http://www.morleydev.co.uk/
Re: How to calculate FPS in SFML 2.0?
« Reply #1 on: October 07, 2012, 03:30:42 pm »
When the number is very big or very small, it's expressed in the scientific notation.
UnitTest11 - A unit testing library in C++ written to take advantage of C++11.

All code is guilty until proven innocent, unworthy until tested, and pointless without singular and well-defined purpose.

binary1248

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1405
  • I am awesome.
    • View Profile
    • The server that really shouldn't be running
Re: How to calculate FPS in SFML 2.0?
« Reply #2 on: October 08, 2012, 09:53:42 am »
If you are asking how SFML calculates the framerate an application is running at, the simple answer is: it doesn't, you have to do it yourself.

If you are asking how to calculate the framerate in an SFML application, the answer is: just like in any other application, count the number of frames every second.

How you output a value is a totally different question. Time measurement has nothing to directly do with FPS, FPS is derived from time.

If you want to learn how to use timers and the time constructs in SFML 2.0 look here: http://sfml-dev.org/tutorials/2.0/system-time.php
SFGUI # SFNUL # GLS # Wyrm <- Why do I waste my time on such a useless project? Because I am awesome (first meaning).

Qix

  • Full Member
  • ***
  • Posts: 139
  • I am Qix!
    • View Profile
    • Natoga Technologies
Re: How to calculate FPS in SFML 2.0?
« Reply #3 on: October 08, 2012, 07:35:59 pm »
Just a tip; if you want to know for development only, use Fraps (it's what I use). It puts the FPS in the corner.

However, if you want to do it in your code, refer to this SO answer.
~ Qix
Creator of Rippl Studio
Code: [Select]
<danharibo> iostream: I don't do enough drugs to think that's a good idea.