aurora: imgui scale change fixes

This commit is contained in:
Luke Street 2022-02-27 12:24:16 -05:00
parent 1583248896
commit 594921789c
3 changed files with 12 additions and 1 deletions

View File

@ -73,6 +73,9 @@ static bool poll_events() noexcept {
break;
}
if (size.scale != g_windowSize.scale) {
if (g_windowSize.scale > 0.f) {
Log.report(logvisor::Info, FMT_STRING("Display scale changed to {}"), size.scale);
}
g_AppDelegate->onAppDisplayScaleChanged(size.scale);
}
g_windowSize = size;

View File

@ -52,11 +52,18 @@ void process_event(const SDL_Event& event) noexcept {
}
void new_frame(const WindowSize& size) noexcept {
if (g_scale != size.scale) {
if (g_scale > 0.f) {
// TODO wgpu backend bug: doesn't clear bind groups on invalidate
g_resources.ImageBindGroups.Clear();
ImGui_ImplWGPU_CreateDeviceObjects();
}
g_scale = size.scale;
}
ImGui_ImplWGPU_NewFrame();
ImGui_ImplSDL2_NewFrame();
// Render at full DPI
g_scale = size.scale;
ImGui::GetIO().DisplaySize = ImVec2{static_cast<float>(size.fb_width), static_cast<float>(size.fb_height)};
ImGui::NewFrame();
}

View File

@ -29,6 +29,7 @@ ImTextureID ImGuiEngine::metaforceIcon;
void ImGuiEngine_Initialize(float scale) {
ImGui::GetCurrentContext();
ImGuiIO& io = ImGui::GetIO();
io.Fonts->Clear();
auto* fontData = new uint8_t[NOTO_MONO_FONT_DECOMPRESSED_SZ];
{