diff --git a/src/hello_imgui/internal/backend_impls/abstract_runner.cpp b/src/hello_imgui/internal/backend_impls/abstract_runner.cpp index ddd99c34..2f6ed1c6 100644 --- a/src/hello_imgui/internal/backend_impls/abstract_runner.cpp +++ b/src/hello_imgui/internal/backend_impls/abstract_runner.cpp @@ -703,7 +703,6 @@ void AbstractRunner::Setup() Impl_Select_Gl_Version(); #endif - SetupDpiAwareParams(); PrepareWindowGeometry(); auto fnRenderCallbackDuringResize = [this]() @@ -730,6 +729,9 @@ void AbstractRunner::Setup() Impl_SetWindowIcon(); + SetupDpiAwareParams(); + + // This should be done before Impl_LinkPlatformAndRenderBackends() // because, in the case of glfw ImGui_ImplGlfw_InstallCallbacks // will chain the user callbacks with ImGui callbacks; diff --git a/src/hello_imgui/internal/hello_imgui_ini_settings.cpp b/src/hello_imgui/internal/hello_imgui_ini_settings.cpp index 79f7418f..2098cb19 100644 --- a/src/hello_imgui/internal/hello_imgui_ini_settings.cpp +++ b/src/hello_imgui/internal/hello_imgui_ini_settings.cpp @@ -243,11 +243,16 @@ namespace HelloImGui // DpiWindowSizeFactor was added late, so it may not be present in the ini file if (appWindowSection.find("DpiWindowSizeFactor") != appWindowSection.end()) { - float dpiWindowSizeFactor_WhenSaved = iniFile["AppWindow"]["DpiWindowSizeFactor"].as(); - bool isDpiSane = (dpiWindowSizeFactor_WhenSaved >= 0.1) || (dpiWindowSizeFactor_WhenSaved <= 10.0); + float dpiWindowSizeFactor_Now = + HelloImGui::GetRunnerParams()->dpiAwareParams.dpiWindowSizeFactor; + float dpiWindowSizeFactor_WhenSaved = + iniFile["AppWindow"]["DpiWindowSizeFactor"].as(); + bool isDpiSane = (dpiWindowSizeFactor_WhenSaved >= 0.1f) && + (dpiWindowSizeFactor_WhenSaved <= 10.f) && + (dpiWindowSizeFactor_Now > 0.1f) && + (dpiWindowSizeFactor_Now < 10.f); if (isDpiSane) { - float dpiWindowSizeFactor_Now = HelloImGui::GetRunnerParams()->dpiAwareParams.dpiWindowSizeFactor; float ratio = dpiWindowSizeFactor_Now / dpiWindowSizeFactor_WhenSaved; if (ratio != 1.f) {