From 43255b01fa90e8d1095cc85a4c36537dabfdba48 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sun, 29 Jul 2018 22:11:24 +0200 Subject: [PATCH] Reduce viewer frame rate when it doesn't have focus. --- standalone/src/main.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/standalone/src/main.cpp b/standalone/src/main.cpp index 0b8f7d3c..5240a1bc 100644 --- a/standalone/src/main.cpp +++ b/standalone/src/main.cpp @@ -252,6 +252,11 @@ int main( int argc, char** argv ) ImGui::Render(); ImGui_ImplGlfwGL3_RenderDrawData(ImGui::GetDrawData()); glfwSwapBuffers(window); + + if( !glfwGetWindowAttrib( window, GLFW_FOCUSED ) ) + { + std::this_thread::sleep_for( std::chrono::milliseconds( 50 ) ); + } } // Cleanup