Fix window resize not affecting ImGui
@@ -288,12 +288,15 @@ bool D3D12::InitializeImGui(size_t aBuffersCounts)
// do this once, do not repeat context creation!
IMGUI_CHECKVERSION();
ImGui::CreateContext();
+
+ }
+
ImGuiIO& io = ImGui::GetIO();
ImGui::StyleColorsDark();
// TODO - scale by DPI
const auto [resx, resy] = GetResolution();
- const auto baseScale = (static_cast<float>(resx) / 1920.0f) * (static_cast<float>(resy) / 1080.0f);
+ const auto baseScale = std::min(static_cast<float>(resx) / 1920.0f, static_cast<float>(resy) / 1080.0f);
ImGui::GetStyle().ScaleAllSizes(baseScale);
@@ -301,6 +304,8 @@ bool D3D12::InitializeImGui(size_t aBuffersCounts)
config.SizePixels = static_cast<int32_t>(m_options.FontSize * baseScale);
config.OversampleH = config.OversampleV = 2;
config.PixelSnapH = true;
+
+ io.Fonts->Clear();
io.Fonts->AddFontDefault(&config);
if (!m_options.FontPath.empty())
@@ -377,7 +382,7 @@ bool D3D12::InitializeImGui(size_t aBuffersCounts)
}
}
}
- }
+
if (!ImGui_ImplWin32_Init(m_window.GetWindow()))
{
