diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 1aa9fe0427..eea35a2edf 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -338,6 +338,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : _lastNackTime(usecTimestampNow()), _lastSendDownstreamAudioStats(usecTimestampNow()), _isVSyncOn(true), + _isThrottleFPSEnabled(true), _aboutToQuit(false), _notifiedPacketVersionMismatchThisDomain(false), _domainConnectionRefusals(QList()), @@ -4612,6 +4613,10 @@ void Application::setVSyncEnabled() { #endif } +void Application::setThrottleFPSEnabled() { + _isThrottleFPSEnabled = Menu::getInstance()->isOptionChecked(MenuOption::ThrottleFPSIfNotFocus); +} + bool Application::isVSyncOn() const { #if defined(Q_OS_WIN) if (wglewGetExtension("WGL_EXT_swap_control")) { diff --git a/interface/src/Application.h b/interface/src/Application.h index 1fe1acb25a..0cdae2289f 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -421,6 +421,9 @@ public slots: void domainSettingsReceived(const QJsonObject& domainSettingsObject); void setVSyncEnabled(); + + void setThrottleFPSEnabled(); + bool isThrottleFPSEnabled() { return _isThrottleFPSEnabled; } void resetSensors(); void setActiveFaceTracker(); @@ -637,6 +640,7 @@ private: quint64 _lastSendDownstreamAudioStats; bool _isVSyncOn; + bool _isThrottleFPSEnabled; bool _aboutToQuit; diff --git a/interface/src/GLCanvas.cpp b/interface/src/GLCanvas.cpp index aff7c75cc9..be7ed6ec72 100644 --- a/interface/src/GLCanvas.cpp +++ b/interface/src/GLCanvas.cpp @@ -35,7 +35,8 @@ void GLCanvas::stopFrameTimer() { } bool GLCanvas::isThrottleRendering() const { - return _throttleRendering || Application::getInstance()->getWindow()->isMinimized(); + return (_throttleRendering + || (Application::getInstance()->getWindow()->isMinimized() && Application::getInstance()->isThrottleFPSEnabled())); } int GLCanvas::getDeviceWidth() const { @@ -59,7 +60,8 @@ void GLCanvas::initializeGL() { void GLCanvas::paintGL() { PROFILE_RANGE(__FUNCTION__); - if (!_throttleRendering && !Application::getInstance()->getWindow()->isMinimized()) { + if (!_throttleRendering + && (!Application::getInstance()->getWindow()->isMinimized()) || !Application::getInstance()->isThrottleFPSEnabled()) { Application::getInstance()->paintGL(); } } @@ -85,7 +87,8 @@ void GLCanvas::activeChanged(Qt::ApplicationState state) { default: // Otherwise, throttle. - if (!_throttleRendering && !Application::getInstance()->isAboutToQuit()) { + if (!_throttleRendering && !Application::getInstance()->isAboutToQuit() + && Application::getInstance()->isThrottleFPSEnabled()) { _frameTimer.start(_idleRenderInterval); _throttleRendering = true; } diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index 7213d4eb79..6115cb673e 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -373,6 +373,8 @@ Menu::Menu() { addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::RenderTargetFramerateVSyncOn, 0, true, qApp, SLOT(setVSyncEnabled())); #endif + addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::ThrottleFPSIfNotFocus, 0, true, + qApp, SLOT(setThrottleFPSEnabled())); } diff --git a/interface/src/Menu.h b/interface/src/Menu.h index 22f07699a0..bd67c09f55 100644 --- a/interface/src/Menu.h +++ b/interface/src/Menu.h @@ -280,6 +280,7 @@ namespace MenuOption { const QString SuppressShortTimings = "Suppress Timings Less than 10ms"; const QString TestPing = "Test Ping"; const QString ThirdPerson = "Third Person"; + const QString ThrottleFPSIfNotFocus = "Throttle FPS If Not Focus"; const QString ToolWindow = "Tool Window"; const QString TransmitterDrive = "Transmitter Drive"; const QString TurnWithHead = "Turn using Head";