Skip to content

Commit

Permalink
Trigger window resize flow on GLFW3 when the window content scale cha…
Browse files Browse the repository at this point in the history
…nges, most commonly caused by moving window between monitors. Addresses issue 3448
  • Loading branch information
dri-richard committed Jul 23, 2024
1 parent b1a11c6 commit 2767c84
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions engine/platform/src/platform_window_glfw3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 2767c84

Please sign in to comment.