SFML community forums

Help => General => Topic started by: Chunker120 on October 07, 2012, 03:21:47 pm

Title: How to calculate FPS in SFML 2.0?
Post by: Chunker120 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?
Title: Re: How to calculate FPS in SFML 2.0?
Post by: MorleyDev on October 07, 2012, 03:30:42 pm
When the number is very big or very small, it's expressed in the scientific notation (http://en.wikipedia.org/wiki/Scientific_notation).
Title: Re: How to calculate FPS in SFML 2.0?
Post by: binary1248 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
Title: Re: How to calculate FPS in SFML 2.0?
Post by: Qix 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 (http://stackoverflow.com/questions/87304/calculating-frames-per-second-in-a-game).