My Project
FrameRateController.h
1 #pragma once
2 
3 namespace ParaEngine
4 {
11 {
12 public:
13  enum ControllerType{
14  FRC_NONE = 0, // output delta time without interpolation
15  FRC_CONSTANT, // output a constant delta time disregarding the input time
16  FRC_CONSTANT_OR_ABOVE, // output a constant delta time or a smaller one
17  FRC_FIRSTORDER, // interpolating using a linear function
18  FRC_SECONDORDER, // interpolating using a second order function
19  FRC_BELOW, // ensure that frame rate is smaller than a given value.
20  FRC_CONSTANT_OR_BELOW, // output a constant delta time or a smaller one
21  };
22 
23  ControllerType m_nType;
27 
30  double m_fNextTime;
31 public:
32 
33  double m_fTime;
34  double m_fLastTime;
35 
36  double m_fElapsedTime;
38 
39 public:
40  CFrameRateController(ControllerType type);
42  ~CFrameRateController(void);
43 public:
45  double GetTime(){return m_fTime;}
47  //double GetElapsedTime(){return m_fElapsedTime;}
48 public:
50  void SetType(ControllerType nType);
51 
53  void SetConstDeltaTime(double fConstDeltaTime);
54 
56  double FrameMove(double time);
57 
59  double FrameMoveDelta(double deltatime);
60 
61 public:
62  static void LoadFRCNormal(float fIdealInterval = -1.f);
63  static void LoadFRCRealtime(float fIdealInterval = -1.f);
64  static void LoadFRCCapture(int nFPS);
65  static void LoadFRCServerMode();
66 };
67 
68 }
static void LoadFRCRealtime(float fIdealInterval=-1.f)
Real time frame rate control.
Definition: FrameRateController.cpp:53
void SetConstDeltaTime(double fConstDeltaTime)
set const delta time.
Definition: FrameRateController.cpp:279
float m_fMaxLinearDeltaTime
Slope for linear interpolation.d(dT)/d(n)
Definition: FrameRateController.h:29
double FrameMoveDelta(double deltatime)
frame move by a delta time
Definition: FrameRateController.cpp:133
different physics engine has different winding order.
Definition: EventBinding.h:32
double m_fLastElapsedTime
current elapsed time
Definition: FrameRateController.h:37
double FrameMove(double time)
frame move by an absolute current time
Definition: FrameRateController.cpp:141
double m_fTime
the next ideal time to be called.
Definition: FrameRateController.h:33
the class for all frame rate controller.
Definition: FrameRateController.h:10
float m_fMaxDeltaTime
the Ideal delta Time rate
Definition: FrameRateController.h:25
void SetType(ControllerType nType)
get the elapsed time: this function is disabled for a reason.
Definition: FrameRateController.cpp:125
float m_fConstDeltaTime
Frame Rate Controller Type.
Definition: FrameRateController.h:24
double GetTime()
get the time in seconds
Definition: FrameRateController.h:45
double m_fElapsedTime
last time, when framemove() is called
Definition: FrameRateController.h:36
double m_fNextTime
the largest delta Time we could tolerate at linear interpolation mode
Definition: FrameRateController.h:30
float m_fMinDeltaTime
the largest delta Time we could tolerate
Definition: FrameRateController.h:26
float m_fLinearSlope
the smallest delta Time we allow, some module need frame rate to be under a certain value ...
Definition: FrameRateController.h:28
static void LoadFRCNormal(float fIdealInterval=-1.f)
load the normal frame rate control configuration
Definition: FrameRateController.cpp:31
double m_fLastTime
current time
Definition: FrameRateController.h:34