Viewports: fixed viewport->FramebufferScale being reset. Amend 98a66d8. (#9502)

This commit is contained in:
ocornut
2026-08-05 15:54:39 +02:00
parent 11bd4e7731
commit 91b131e448
+6 -1
View File
@@ -17425,11 +17425,16 @@ ImGuiViewportP* ImGui::AddUpdateViewport(ImGuiWindow* window, ImGuiID id, const
}
viewport->Window = window;
viewport->FramebufferScale = g.IO.DisplayFramebufferScale; // Later overidden by Platform_GetWindowFramebufferScale() for platform having it
viewport->LastFrameActive = g.FrameCount;
viewport->UpdateWorkRect();
IM_ASSERT(window == NULL || viewport->ID == window->ID);
// Initialize FramebufferScale for new viewports, before UpdatePlatformWindows() -> Platform_GetWindowFramebufferScale() has a chance to run.
// FIXME: New viewport on monitors with a different scale will run for a frame with wrong scale? (#9502)
// A workaround could be to cache last known FramebufferScale per monitor, so the heuristic can pull it from monitor.
if (viewport->FramebufferScale.x <= 0.0f || viewport->FramebufferScale.y <= 0.0f)
viewport->FramebufferScale = g.IO.DisplayFramebufferScale;
if (window != NULL)
window->ViewportOwned = true;