Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jul 14, 2009, 10:09:12 AM (15 years ago)
Author:
scheusso
Message:

a fix in Clock (more ogre-overflow safe now)
moved framerate control from gsdedicated to game
desired framerate can be controlled by config value FPSLimit_ (in the Game class) now

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/netp6/src/core/Game.cc

    r3196 r3289  
    4040#include "util/Debug.h"
    4141#include "util/Exception.h"
     42#include "util/Sleep.h"
    4243#include "util/SubString.h"
    4344#include "Clock.h"
     
    120121        SetConfigValue(levelName_, "presentation_dm.oxw")
    121122            .description("Sets the preselection of the level in the main menu.");
     123      SetConfigValue(FPSLimit_, 50)
     124            .description("Sets the desired framerate (0 for no limit).");
    122125    }
    123126
     
    156159        while (!this->abort_ && !this->activeStates_.empty())
    157160        {
     161            uint64_t currentTime = this->gameClock_->getRealMicroseconds();
     162
     163            uint64_t nextTickTime = statisticsTickTimes_.back().tickTime + 1000000.f/this->FPSLimit_;
     164            if( currentTime < nextTickTime )
     165            {
     166                usleep( nextTickTime - currentTime );
     167                continue;
     168            }
    158169            this->gameClock_->capture();
    159             uint64_t currentTime = this->gameClock_->getMicroseconds();
    160170
    161171            // STATISTICS
Note: See TracChangeset for help on using the changeset viewer.