SFML community forums

Bindings - other languages => Python => Topic started by: Kubik on September 05, 2012, 09:04:02 pm

Title: Problem with getting fps
Post by: Kubik on September 05, 2012, 09:04:02 pm
I try to get fps by this way:
self.FPS = 1.0 / self.window.GetFrameTime(), but get ZeroDivisionError: float division, so how get fps
Title: Re: Problem with getting fps
Post by: Laurent on September 05, 2012, 10:21:41 pm
Make sure that self.window.GetFrameTime() is not zero.
Title: Re: Problem with getting fps
Post by: Kubik on September 05, 2012, 10:52:32 pm
i know that and i know reason of problem i try to conversion types, not helped
Title: Re: Problem with getting fps
Post by: eXpl0it3r on September 05, 2012, 10:55:38 pm
i know that and i know reason of problem i try to conversion types, not helped
Hu? ???
You get a devision by Zero most probably because GetFrameTime() is 0, I don't see what this has to do with type conversion...
Title: Re: Problem with getting fps
Post by: Kubik on September 05, 2012, 10:58:14 pm
yes, i don't write in example type conversion, but why i get zero? maybe i must do anything else? How get fps?
Title: Re: Problem with getting fps
Post by: eXpl0it3r on September 05, 2012, 11:22:34 pm
It's not your 'fault' that GetFrameTime() returns 0, it's the inaccuracy of floats...
Have you taken a look at the Python binding for SFML 2, because the API has changed and a new class was introduced sf::Time which works around this problem.

To 'fix' your problem with the binding you're using now, you can either check if GetFrameTime() is zero and if so, define the FPS as infinite or very very high, or you could always blindly add some small number to it (e.g. 0.00001)
Title: Re: Problem with getting fps
Post by: Kubik on September 05, 2012, 11:26:35 pm
 :) no i would use fraps, thank you