@ -676,6 +676,7 @@ void OMW::Engine::go()
// Start the main rendering loop
// Start the main rendering loop
osg : : Timer frameTimer ;
osg : : Timer frameTimer ;
double simulationTime = 0.0 ;
double simulationTime = 0.0 ;
float framerateLimit = Settings : : Manager : : getFloat ( " framerate limit " , " Video " ) ;
while ( ! mViewer - > done ( ) & & ! mEnvironment . getStateManager ( ) - > hasQuitRequest ( ) )
while ( ! mViewer - > done ( ) & & ! mEnvironment . getStateManager ( ) - > hasQuitRequest ( ) )
{
{
double dt = frameTimer . time_s ( ) ;
double dt = frameTimer . time_s ( ) ;
@ -693,6 +694,7 @@ void OMW::Engine::go()
if ( ! mEnvironment . getInputManager ( ) - > isWindowVisible ( ) )
if ( ! mEnvironment . getInputManager ( ) - > isWindowVisible ( ) )
{
{
OpenThreads : : Thread : : microSleep ( 5000 ) ;
OpenThreads : : Thread : : microSleep ( 5000 ) ;
continue ;
}
}
else
else
{
{
@ -700,6 +702,16 @@ void OMW::Engine::go()
mViewer - > updateTraversal ( ) ;
mViewer - > updateTraversal ( ) ;
mViewer - > renderingTraversals ( ) ;
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
// Save user settings