Browse Source

Allow C++ access to Engine's next frame timestep.

Lasse Öörni 11 years ago
parent
commit
aa6d76551f
2 changed files with 9 additions and 0 deletions
  1. 5 0
      Source/Engine/Engine/Engine.cpp
  2. 4 0
      Source/Engine/Engine/Engine.h

+ 5 - 0
Source/Engine/Engine/Engine.cpp

@@ -504,6 +504,11 @@ void Engine::SetAutoExit(bool enable)
     autoExit_ = enable;
 }
 
+void Engine::SetNextTimeStep(float seconds)
+{
+    timeStep_ = Max(seconds, 0.0f);
+}
+
 void Engine::Exit()
 {
 #if defined(IOS)

+ 4 - 0
Source/Engine/Engine/Engine.h

@@ -62,6 +62,8 @@ public:
     void SetPauseMinimized(bool enable);
     /// Set whether to exit automatically on exit request (window close button.)
     void SetAutoExit(bool enable);
+    /// Override timestep of the next frame. Should be called in between RunFrame() calls.
+    void SetNextTimeStep(float seconds);
     /// Close the graphics window and set the exit flag. No-op on iOS, as an iOS application can not legally exit.
     void Exit();
     /// Dump profiling information to the log.
@@ -71,6 +73,8 @@ public:
     /// Dump information of all memory allocations to the log. Supported in MSVC debug mode only.
     void DumpMemory();
     
+    /// Get timestep of the next frame. Updated by ApplyFrameLimit().
+    float GetNextTimeStep() const { return timeStep_; }
     /// Return the minimum frames per second.
     int GetMinFps() const { return minFps_; }
     /// Return the maximum frames per second.