forked from mirror/openmw-tes3mp
Implement framerate limit setting
The framerate limit can be used to reduce strain on the CPU and GPU, in a way similar to VSync, but without the increased input lag that is typical with VSync.
This commit is contained in:
parent
96e3933ee9
commit
481f23d955
2 changed files with 15 additions and 0 deletions
|
@ -676,6 +676,7 @@ void OMW::Engine::go()
|
|||
// Start the main rendering loop
|
||||
osg::Timer frameTimer;
|
||||
double simulationTime = 0.0;
|
||||
float framerateLimit = Settings::Manager::getFloat("framerate limit", "Video");
|
||||
while (!mViewer->done() && !mEnvironment.getStateManager()->hasQuitRequest())
|
||||
{
|
||||
double dt = frameTimer.time_s();
|
||||
|
@ -693,6 +694,7 @@ void OMW::Engine::go()
|
|||
if (!mEnvironment.getInputManager()->isWindowVisible())
|
||||
{
|
||||
OpenThreads::Thread::microSleep(5000);
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -700,6 +702,16 @@ void OMW::Engine::go()
|
|||
mViewer->updateTraversal();
|
||||
mViewer->renderingTraversals();
|
||||
}
|
||||
|
||||
if (framerateLimit > 0.f)
|
||||
{
|
||||
double thisFrameTime = frameTimer.time_s();
|
||||
double minFrameTime = 1.0 / framerateLimit;
|
||||
if (thisFrameTime < minFrameTime)
|
||||
{
|
||||
OpenThreads::Thread::microSleep(1000*1000*(minFrameTime-thisFrameTime));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Save user settings
|
||||
|
|
|
@ -20,6 +20,9 @@ vsync = false
|
|||
gamma = 1.00
|
||||
contrast = 1.00
|
||||
|
||||
# Maximum framerate in frames per second, 0 = unlimited
|
||||
framerate limit = 0
|
||||
|
||||
[GUI]
|
||||
scaling factor = 1.0
|
||||
|
||||
|
|
Loading…
Reference in a new issue