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