Changeset 3304 for code/trunk/src/core/Game.cc
- Timestamp:
- Jul 18, 2009, 6:23:31 PM (16 years ago)
- Location:
- code/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
/code/branches/netp6 (added) merged: 3215,3226-3227,3229-3231,3240,3242,3251-3252,3256,3258-3259,3263-3264,3267-3268,3277,3283-3284,3289,3298-3299,3302
- Property svn:mergeinfo changed
-
code/trunk/src/core/Game.cc
r3300 r3304 40 40 #include "util/Debug.h" 41 41 #include "util/Exception.h" 42 #include "util/Sleep.h" 42 43 #include "util/SubString.h" 43 44 #include "Clock.h" … … 95 96 SetConfigValue(statisticsAvgLength_, 1000000) 96 97 .description("Sets the time in microseconds interval at which average fps, etc. gets calculated."); 98 SetConfigValue(fpsLimit_, 50) 99 .description("Sets the desired framerate (0 for no limit)."); 97 100 } 98 101 99 102 unsigned int statisticsRefreshCycle_; 100 103 unsigned int statisticsAvgLength_; 104 unsigned int fpsLimit_; 101 105 }; 102 106 … … 192 196 193 197 // START GAME 194 this->gameClock_->capture(); // first delta time should be about 0 seconds 198 // first delta time should be about 0 seconds 199 this->gameClock_->capture(); 200 // A first item is required for the fps limiter 201 StatisticsTickInfo tickInfo = {0, 0}; 202 statisticsTickTimes_.push_back(tickInfo); 195 203 while (!this->bAbort_ && (!this->activeStates_.empty() || this->requestedStateNodes_.size() > 0)) 196 204 { 205 uint64_t currentTime = this->gameClock_->getRealMicroseconds(); 206 207 uint64_t nextTickTime = statisticsTickTimes_.back().tickTime + static_cast<uint64_t>(1000000.0f / configuration_->fpsLimit_); 208 if (currentTime < nextTickTime) 209 { 210 usleep(nextTickTime - currentTime); 211 continue; 212 } 197 213 this->gameClock_->capture(); 198 uint64_t currentTime = this->gameClock_->getMicroseconds();199 214 200 215 // STATISTICS
Note: See TracChangeset
for help on using the changeset viewer.