From 2767c8419c1be9c11197307a85979f09eb5effe9 Mon Sep 17 00:00:00 2001 From: Richard Bates Date: Tue, 23 Jul 2024 12:09:10 +0100 Subject: [PATCH] Trigger window resize flow on GLFW3 when the window content scale changes, most commonly caused by moving window between monitors. Addresses issue 3448 --- engine/platform/src/platform_window_glfw3.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/engine/platform/src/platform_window_glfw3.cpp b/engine/platform/src/platform_window_glfw3.cpp index f2d1ca3e50d..761fa18c8f3 100644 --- a/engine/platform/src/platform_window_glfw3.cpp +++ b/engine/platform/src/platform_window_glfw3.cpp @@ -101,6 +101,13 @@ namespace dmPlatform } } + static void OnContentScaleCallback(GLFWwindow* glfw_window, float xscale, float yscale) + { + int width, height; + glfwGetWindowSize(glfw_window, &width, &height); + OnWindowResize(glfw_window, width, height); + } + static void OnMouseScroll(GLFWwindow* glfw_window, double xoffset, double yoffset) { HWindow window = (HWindow) glfwGetWindowUserPointer(glfw_window); @@ -259,6 +266,7 @@ namespace dmPlatform glfwSetScrollCallback(window->m_Window, OnMouseScroll); glfwSetCharCallback(window->m_Window, OnAddCharacterCallback); glfwSetMarkedTextCallback(window->m_Window, OnMarkedTextCallback); + glfwSetWindowContentScaleCallback(window->m_Window, OnContentScaleCallback); glfwSetJoystickCallback(OnJoystick);