forked from Phobos-developers/YRpp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFPSCounter.h
47 lines (37 loc) · 1.11 KB
/
FPSCounter.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
#pragma once
class FPSCounter
{
public:
//!< The number of frames processed in the last second.
static unsigned int &CurrentFrameRate;
//!< The total number of frames elapsed.
static unsigned int &TotalFramesElapsed;
//!< The time it took to process TotalFramesElapsed frames.
static unsigned int &TotalTimeElapsed;
//!< Whether the current fps is considered too low.
static bool &ReducedEffects;
//!< The average frame rate for all frames processed.
static inline double GetAverageFrameRate()
{
if(TotalTimeElapsed) {
return static_cast<double>(TotalFramesElapsed)
/ static_cast<double>(TotalTimeElapsed);
}
return 0.0;
}
};
class Detail {
public:
//!< What is considered the minimum acceptable FPS.
static unsigned int &MinFrameRate;
//!< The zone that needs to be left to change
static unsigned int &BufferZoneWidth;
//!< The minimum frame rate considering the buffer zone.
static inline unsigned int GetMinFrameRate()
{ JMP_STD(0x55AF60); }
//!< Whether effects should be reduced.
static inline bool ReduceEffects()
{
return FPSCounter::CurrentFrameRate < GetMinFrameRate();
}
};