-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathFPSGraph.cpp
More file actions
49 lines (39 loc) · 811 Bytes
/
FPSGraph.cpp
File metadata and controls
49 lines (39 loc) · 811 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include "FPSGraph.h"
#include "Application.h"
#include "Time.h"
FPSGraph::FPSGraph()
{
App->SetMaxFPS(max_fps);
time->SetMaxFPS(max_fps);
}
FPSGraph::~FPSGraph()
{}
void FPSGraph::Draw()
{
if (!active)
return;
int fps = time->GetFPS();
//Get frames
if (frames.size() > 100) //Max seconds to show
{
for (size_t i = 1; i < frames.size(); i++)
{
frames[i-1] = frames[i];
}
frames[frames.size() - 1] = fps;
}
else
{
frames.push_back(fps);
}
ImGui::Begin("FPS Graph", &active, flags);
char text[20];
sprintf_s(text, 20, "Frames: %d", fps);
ImGui::Text(text);
ImGui::PlotHistogram("Framerate", &frames[0], frames.size(), 0, NULL, 0.0f, 100.0f, ImVec2(300, 100));
if (ImGui::SliderInt("Max FPS", &max_fps, -1, 200, NULL))
{
time->SetMaxFPS(max_fps);
}
ImGui::End();
}