/
RenderStatistics.h
49 lines (39 loc) · 1.06 KB
/
RenderStatistics.h
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
48
49
#pragma once
#include <wx/stopwatch.h>
#include "string/string.h"
namespace render
{
/// Storage class for per-frame render statistics
class RenderStatistics
{
// Timer for measuring render time
wxStopWatch _timer;
// Count of lights (visible and culled)
int _visibleLights = 0;
int _culledLights = 0;
public:
/// Return the constructed string for display
std::string getStatString()
{
long msec = _timer.Time();
return "lights: " + std::to_string(_visibleLights)
+ " / " + std::to_string(_visibleLights + _culledLights)
+ " | msec: " + std::to_string(msec)
+ " | fps: " + (msec > 0 ? std::to_string(1000 / msec) : "-");
}
/// Increment the light count
void addLight(bool visible)
{
if (visible)
++_visibleLights;
else
++_culledLights;
}
/// Reset statistics at the beginning of a frame render
void resetStats()
{
_visibleLights = _culledLights = 0;
_timer.Start();
}
};
} // namespace render