[Orxonox-commit 1456] r6174 - code/branches/presentation2/src/libraries/core

rgrieder at orxonox.net rgrieder at orxonox.net
Sat Nov 28 18:06:57 CET 2009


Author: rgrieder
Date: 2009-11-28 18:06:57 +0100 (Sat, 28 Nov 2009)
New Revision: 6174

Modified:
   code/branches/presentation2/src/libraries/core/Game.cc
Log:
Moved fps hack to the right position. I still have no idea why the fps rate was one frame too low.

Modified: code/branches/presentation2/src/libraries/core/Game.cc
===================================================================
--- code/branches/presentation2/src/libraries/core/Game.cc	2009-11-27 12:11:53 UTC (rev 6173)
+++ code/branches/presentation2/src/libraries/core/Game.cc	2009-11-28 17:06:57 UTC (rev 6174)
@@ -306,7 +306,8 @@
             }
 
             uint32_t framesPerPeriod = this->statisticsTickTimes_.size();
-            this->avgFPS_ = static_cast<float>(framesPerPeriod) / (currentTime - this->statisticsTickTimes_.front().tickTime) * 1000000.0f;
+            // Why plus 1? No idea, but otherwise the fps rate is always (from 10 to 200!) one frame too low
+            this->avgFPS_ = 1 + static_cast<float>(framesPerPeriod) / (currentTime - this->statisticsTickTimes_.front().tickTime) * 1000000.0f;
             this->avgTickTime_ = static_cast<float>(this->periodTickTime_) / framesPerPeriod / 1000.0f;
 
             this->periodTime_ -= this->statisticsRefreshCycle_;
@@ -315,8 +316,7 @@
 
     void Game::updateFPSLimiter()
     {
-        // Why fpsLimit_ - 1? No idea, but otherwise the fps rate is always (from 10 to 200!) one frame too high
-        uint32_t nextTime = gameClock_->getMicroseconds() - excessSleepTime_ + static_cast<uint32_t>(1000000.0f / (fpsLimit_ - 1));
+        uint32_t nextTime = gameClock_->getMicroseconds() - excessSleepTime_ + static_cast<uint32_t>(1000000.0f / fpsLimit_);
         uint64_t currentRealTime = gameClock_->getRealMicroseconds();
         while (currentRealTime < nextTime - minimumSleepTime_)
         {




More information about the Orxonox-commit mailing list