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

Author Topic: Problem with getting fps  (Read 5180 times)

0 Members and 1 Guest are viewing this topic.

Kubik

  • Newbie
  • *
  • Posts: 13
    • View Profile
    • Email
Problem with getting fps
« 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

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Problem with getting fps
« Reply #1 on: September 05, 2012, 10:21:41 pm »
Make sure that self.window.GetFrameTime() is not zero.
Laurent Gomila - SFML developer

Kubik

  • Newbie
  • *
  • Posts: 13
    • View Profile
    • Email
Re: Problem with getting fps
« Reply #2 on: September 05, 2012, 10:52:32 pm »
i know that and i know reason of problem i try to conversion types, not helped

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10821
    • View Profile
    • development blog
    • Email
Re: Problem with getting fps
« Reply #3 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...
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Kubik

  • Newbie
  • *
  • Posts: 13
    • View Profile
    • Email
Re: Problem with getting fps
« Reply #4 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?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10821
    • View Profile
    • development blog
    • Email
Re: Problem with getting fps
« Reply #5 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)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Kubik

  • Newbie
  • *
  • Posts: 13
    • View Profile
    • Email
Re: Problem with getting fps
« Reply #6 on: September 05, 2012, 11:26:35 pm »
 :) no i would use fraps, thank you