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

Author Topic: How do you get the 60 value fps  (Read 1511 times)

0 Members and 1 Guest are viewing this topic.

PewPew

  • Newbie
  • *
  • Posts: 22
    • View Profile
How do you get the 60 value fps
« on: July 07, 2016, 02:43:27 pm »
Ive been searching how to get the framerate to display as 60fps in the windows screen

this code

 float Framerate = 1.f / Clock.GetElapsedTime();
    Clock.Reset();
is not suited for that kind of thing.
I saw on some previos post here made by laurent
He said

Quote
There are two ways to compute the FPS:
1. counting how many frames you have in one second (that's your code)
2. counting how many seconds you have in one frame, and inverting the result (that's my code)

Basically I just wanna count how many frames is called in one second?

Hapax

  • Hero Member
  • *****
  • Posts: 3351
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: How do you get the 60 value fps
« Reply #1 on: July 07, 2016, 02:53:40 pm »
Counting how many times something happens each second would involve a timer, a current count and a count total. Since you are adding frames, every frame, add 1 to the current count. Whenever the timer is greater than or equal to a second, set the count total to the current count, reset current count to zero and reset the timer. The count total will then hold the amount of frames that happened in the previous second until the next second has completed.
Note that his updates (approximately) once per second.
A similar code (and an alternative) should be present on the thread you quoted.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

PewPew

  • Newbie
  • *
  • Posts: 22
    • View Profile
Re: How do you get the 60 value fps
« Reply #2 on: July 07, 2016, 03:57:51 pm »
Hi. Thanks I got it from here

https://github.com/SFML/SFML/wiki/Source:-FPS

Anyway just wanna ask does 0 counts in the FPS? cause I set the framelimit on 60 and I most of the time get 61.. weird

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: How do you get the 60 value fps
« Reply #3 on: July 07, 2016, 04:56:57 pm »
The framerate limit is just a hint, and is absolutely not accurate. So 61 is perfectly fine if you asked 60.
Laurent Gomila - SFML developer