ST_engine  0.3-ALPHA
fps.hpp
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 #ifndef FPS_DEF
11 #define FPS_DEF
12 
14 #include <cstdint>
15 #include <algorithm>
16 
21 class fps {
22 
23 private:
24  double old_time = 0;
25  double new_time = 0;
26  float value = 0;
27  float average[16]{};
28 
29  float get_average();
30 
31  uint8_t counter = 0;
32 public:
33  void update(double time, double frame_time);
34 
35  [[nodiscard]] float get_value() const;
36 };
37 
38 #endif //FPS_DEF
An fps counter.
Definition: fps.hpp:21
void update(double time, double frame_time)
Definition: fps.cpp:17
float get_value() const
Definition: fps.cpp:41