All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
EmscriptenFrameRateController.h
1 #pragma once
2 
3 #include "Types.h"
4 #include "EmscriptenTypes.h"
5 
6 namespace Eegeo
7 {
8  namespace Emscripten
9  {
11  {
12  public:
13  static EmscriptenFrameRateController* Create(
14  const EmscriptenFrameRateOptions& emscriptenFrameRateOptions
15  );
16 
17  void Update(double inputIdleTimeSeconds);
18  void Pause();
19  void Resume();
20 
21  bool IsNextFrameDue() const;
22  bool IsPaused() const;
23  float GetCurrentFrameDeltaSeconds() const;
24 
25  void SetTargetVSyncInterval(int targetVSyncInterval);
26  void SetThrottledTargetFrameInterval(int throttledTargetFrameIntervalMS);
27  void SetIdleSecondsBeforeThrottle(float idleSecondsBeforeThrottle);
28  void SetThrottleWhenIdleEnabled(bool enabled);
29  void CancelThrottle();
30 
31  private:
33  int targetVSyncInterval,
34  int throttledTargetFrameIntervalMS,
35  float idleTimeoutSeconds,
36  bool throttleWhenIdleEnabled,
37  bool loggingEnabled
38  );
39 
40  bool ShouldThrottle(double idleTimeSeconds) const;
41 
42  int m_targetVSyncInterval;
43  int m_throttledTargetFrameIntervalMS;
44  float m_idleSecondsBeforeThrottle;
45  bool m_throttleWhenIdleEnabled;
46  bool m_loggingEnabled;
47  bool m_isInitialized;
48  bool m_isThrottled;
49  bool m_isPaused;
50  bool m_isNextFrameDue;
51  double m_previousFrameTimeMilliseconds;
52  float m_currentFrameDeltaSeconds;
53  double m_timeSinceCancelThrottle;
54  int m_frameCount;
55  };
56  }
57 }