Conditional framerate limiting on GLFW.

This commit is contained in:
Bartosz Taudul 2024-03-29 21:59:16 +01:00
parent e85457815e
commit 30f1b901a9
No known key found for this signature in database
GPG Key ID: B7FE2008B7575DF3

View File

@ -13,6 +13,7 @@
#include <stdlib.h>
#include <thread>
#include "profiler/TracyConfig.hpp"
#include "profiler/TracyImGui.hpp"
#include "Backend.hpp"
@ -25,6 +26,9 @@ static RunQueue* s_mainThreadTasks;
static WindowPosition* s_winPos;
static bool s_iconified;
extern tracy::Config s_config;
static void glfw_error_callback( int error, const char* description )
{
fprintf(stderr, "Error %d: %s\n", error, description);
@ -146,10 +150,7 @@ void Backend::Run()
{
glfwPollEvents();
s_redraw();
if( !glfwGetWindowAttrib( s_window, GLFW_FOCUSED ) )
{
std::this_thread::sleep_for( std::chrono::milliseconds( 50 ) );
}
if( s_config.focusLostLimit && !glfwGetWindowAttrib( s_window, GLFW_FOCUSED ) ) std::this_thread::sleep_for( std::chrono::milliseconds( 50 ) );
s_mainThreadTasks->Run();
}
}