ST_engine  0.3-ALPHA
fps.cpp
1 /* This file is part of the "ST" project.
2  * You may use, distribute or modify this code under the terms
3  * of the GNU General Public License version 2.
4  * See LICENCE.txt in the root directory of the project.
5  *
6  * Author: Maxim Atanasov
7  * E-mail: maxim.atanasov@protonmail.com
8  */
9 
10 #include <main/fps.hpp>
11 
17 void fps::update(double time, double frame_time) {
18  average[counter++] = 1000 / frame_time; //TODO: Fix:
19  counter = (counter != 16) * counter;
20  new_time = time;
21  if (new_time - old_time > 64) {
22  value = get_average();
23  old_time = new_time;
24  }
25 }
26 
30 float fps::get_average() {
31  float sum = 0;
32  for (float i: average) {
33  sum += i;
34  }
35  return sum / 16;
36 }
37 
41 float fps::get_value() const {
42  return value;
43 }
void update(double time, double frame_time)
Definition: fps.cpp:17
float get_value() const
Definition: fps.cpp:41