1
0
mirror of https://github.com/wolfpld/tracy synced 2025-04-29 04:23:51 +00:00

Adding per-monitor DPI awareness by using glfwGetWindowContentScale instead of glfwGetMonitorContentScale and ensuring that the window is also resized appropriately by using GLFW_SCALE_TO_MONITOR

This commit is contained in:
Simon van Bernem 2025-04-25 19:44:30 +02:00
parent 753305a797
commit a150fdfc35

View File

@ -80,6 +80,9 @@ Backend::Backend( const char* title, const std::function<void()>& redraw, const
# if GLFW_VERSION_MAJOR > 3 || ( GLFW_VERSION_MAJOR == 3 && GLFW_VERSION_MINOR >= 4 )
glfwWindowHint( GLFW_WIN32_KEYBOARD_MENU, 1 );
# endif
# if GLFW_VERSION_MAJOR > 3 || ( GLFW_VERSION_MAJOR == 3 && GLFW_VERSION_MINOR >= 3 )
glfwWindowHint( GLFW_SCALE_TO_MONITOR, 1 );
# endif
#endif
s_window = glfwCreateWindow( m_winPos.w, m_winPos.h, title, NULL, NULL );
if( !s_window ) exit( 1 );
@ -200,14 +203,10 @@ void Backend::SetTitle( const char* title )
float Backend::GetDpiScale()
{
#if GLFW_VERSION_MAJOR > 3 || ( GLFW_VERSION_MAJOR == 3 && GLFW_VERSION_MINOR >= 3 )
auto monitor = glfwGetWindowMonitor( s_window );
if( !monitor ) monitor = glfwGetPrimaryMonitor();
if( monitor )
{
float x, y;
glfwGetMonitorContentScale( monitor, &x, &y );
return x;
}
#endif
float x, y;
glfwGetWindowContentScale( s_window, &x, &y );
return x;
#else
return 1;
#endif
}