TazGraph Project v0.1.0
Loading...
Searching...
No Matches
FPSCounter.h
1#pragma once
2#include "../UIElement.h"
3#include <Camera2.5D/CameraManager.h>
4
5class FPSCounter : public UIElement {
6private:
7 float cameraRotationZ = 0;
8 const BaseFPSLimiter* baseFPSLimiter;
9
10public:
11 FPSCounter() = default;
12 ~FPSCounter() override = default;
13
14 void OnImGuiRender() override
15 {
16 ImGui::Begin("Performance");
17 ImGui::Text("FPS: %f", baseFPSLimiter->fps);
18 if (ImPlot::BeginPlot("FPS Plot")) {
19 int plot_count = std::min(baseFPSLimiter->fps_history_count,
20 baseFPSLimiter->fpsHistoryIndx); // Ensuring we do not read out of bounds
21 int plot_offset = std::max(0,
22 baseFPSLimiter->fpsHistoryIndx - baseFPSLimiter->fps_history_count); // Ensure a positive offset
23
24 ImPlot::SetupAxesLimits(0, 100, 0, 200);
25
26 ImPlot::PlotLine("FPS", &baseFPSLimiter->fpsHistory[0], plot_count);
27
28 ImPlot::EndPlot();
29 }
30 ImGui::End();
31 };
32
33 void setLimiter(const BaseFPSLimiter& m_baseFPSLimiter) {
34 baseFPSLimiter = &m_baseFPSLimiter;
35 }
36
37};
Definition BaseFPSLimiter.h:5
Definition FPSCounter.h:5
Definition UIElement.h:21