Skip to content

Commit

Permalink
Conditional framerate limiting on GLFW.
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfpld committed Mar 29, 2024
1 parent e854578 commit 30f1b90
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions profiler/src/BackendGlfw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <stdlib.h>
#include <thread>

#include "profiler/TracyConfig.hpp"
#include "profiler/TracyImGui.hpp"

#include "Backend.hpp"
Expand All @@ -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);
Expand Down Expand Up @@ -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();
}
}
Expand Down

0 comments on commit 30f1b90

Please sign in to comment.