forked from Ares-Developers/YRpp
-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathFPSCounter.h
47 lines (37 loc) · 1.23 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.
DEFINE_REFERENCE(unsigned int, CurrentFrameRate, 0xABCD44u)
//!< The total number of frames elapsed.
DEFINE_REFERENCE(unsigned int, TotalFramesElapsed, 0xABCD48u)
//!< The time it took to process TotalFramesElapsed frames.
DEFINE_REFERENCE(unsigned int, TotalTimeElapsed, 0xABCD4Cu)
//!< Whether the current fps is considered too low.
DEFINE_REFERENCE(bool, ReducedEffects, 0xABCD50u)
//!< 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.
DEFINE_REFERENCE(unsigned int, MinFrameRate, 0x829FF4u)
//!< The zone that needs to be left to change
DEFINE_REFERENCE(unsigned int, BufferZoneWidth, 0x829FF8u)
//!< 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();
}
};