vengine  0.1.0
3D graphics engine made with Vulkan
Loading...
Searching...
No Matches
FrameCounter.hpp
Go to the documentation of this file.
1///
2/// @file FrameCounter.hpp
3/// @brief This file contains the FrameCounter class
4/// @namespace ven
5///
6
7#pragma once
8
9#include <iostream>
10
11namespace ven {
12
14
15 public:
16
17 FrameCounter() = default;
18 ~FrameCounter() = default;
19
20 void update(const float deltaTime) {
21 m_frameCounter += 1.F;
22 m_timeCounter += deltaTime;
23
24 if (m_timeCounter >= 1.F) {
25 std::cout << "FPS: " << m_frameCounter << '\n';
27 m_frameTime = 1000.F / m_fps;
28 m_frameCounter = 0.F;
29 m_timeCounter = 0.F;
30 }
31 }
32
33 [[nodiscard]] float getFps() const { return m_fps; }
34 [[nodiscard]] float getFrameTime() const { return m_frameTime; }
35
36 private:
37
38 float m_fps{0.F};
39 float m_frameTime{0.F};
40 float m_frameCounter{0.F};
41 float m_timeCounter{0.F};
42
43 }; // class FrameCounter
44
45} // namespace ven
~FrameCounter()=default
void update(const float deltaTime)
float getFrameTime() const
FrameCounter()=default
float getFps() const