added ability to override throttle settings for future customization if required:

RenderFPSCap=500
RenderFPSCapSleepMillis=1
RenderFPSCapHeadless=250
RenderFPSCapHeadlessSleepMillis=1
This commit is contained in:
Mark Vejvoda 2011-11-08 16:27:15 +00:00
parent 08de3e8f18
commit c8649f8cd1

View File

@ -71,16 +71,18 @@ void ProgramState::tick() {
} }
bool ProgramState::canRender(bool sleepIfCannotRender) { bool ProgramState::canRender(bool sleepIfCannotRender) {
int maxFPSCap = 800; int maxFPSCap = Config::getInstance().getInt("RenderFPSCap","500");
int sleepMillis = Config::getInstance().getInt("RenderFPSCapSleepMillis","1");
Renderer &renderer= Renderer::getInstance(); Renderer &renderer= Renderer::getInstance();
if(renderer.isMasterserverMode() == true) { if(renderer.isMasterserverMode() == true) {
maxFPSCap = 250; maxFPSCap = Config::getInstance().getInt("RenderFPSCapHeadless","250");
sleepMillis = Config::getInstance().getInt("RenderFPSCapHeadlessSleepMillis","1");
} }
if(lastFps > maxFPSCap) { if(lastFps > maxFPSCap) {
if(sleepIfCannotRender == true) { if(sleepIfCannotRender == true) {
sleep(1); sleep(sleepMillis);
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] sleeping because lastFps = %d, maxFPSCap = %d\n",__FILE__,__FUNCTION__,__LINE__,lastFps,maxFPSCap); if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] sleeping because lastFps = %d, maxFPSCap = %d sleepMillis = %d\n",__FILE__,__FUNCTION__,__LINE__,lastFps,maxFPSCap,sleepMillis);
} }
return false; return false;
} }