From 01c273d2fe05eed07e28b610fb84d5d20b3698c2 Mon Sep 17 00:00:00 2001 From: Georg Hagen Date: Sun, 21 Jul 2024 21:49:24 +0200 Subject: [PATCH] Fix window resizing issue --- openVulkanoCpp/Host/GLFW/WindowGLFW.cpp | 14 +++++++++----- openVulkanoCpp/Host/GLFW/WindowGLFW.hpp | 1 + 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/openVulkanoCpp/Host/GLFW/WindowGLFW.cpp b/openVulkanoCpp/Host/GLFW/WindowGLFW.cpp index 6525988..aa61f02 100644 --- a/openVulkanoCpp/Host/GLFW/WindowGLFW.cpp +++ b/openVulkanoCpp/Host/GLFW/WindowGLFW.cpp @@ -149,8 +149,7 @@ namespace OpenVulkano::GLFW void WindowGLFW::SetSize(uint32_t width, uint32_t height) { - windowConfig.size.x = width; - windowConfig.size.y = height; + currentSize = { width, height }; if (window) { glfwSetWindowSize(window, width, height); @@ -169,9 +168,9 @@ namespace OpenVulkano::GLFW Math::Vector2ui WindowGLFW::GetSize() { - Math::Vector2i size; - glfwGetWindowSize(window, &size.x, &size.y); - return size; + if (currentSize.x == 0 || currentSize.y == 0) + glfwGetWindowSize(window, reinterpret_cast(¤tSize.x), reinterpret_cast(¤tSize.y)); + return currentSize; } Math::Vector2i WindowGLFW::GetPosition() @@ -269,6 +268,11 @@ namespace OpenVulkano::GLFW void WindowGLFW::OnResize(const uint32_t newWidth, const uint32_t newHeight) { Logger::WINDOW->debug("Window (id: {0}) resized (width: {1}, height: {2})", GetWindowId(), newWidth, newHeight); + currentSize = { newWidth, newHeight }; + if (GetWindowMode() == WINDOWED || GetWindowMode() == BORDERLESS) + { + windowConfig.size = currentSize; + } handler->OnWindowResize(this, newWidth, newHeight); } diff --git a/openVulkanoCpp/Host/GLFW/WindowGLFW.hpp b/openVulkanoCpp/Host/GLFW/WindowGLFW.hpp index 709468a..fc6844f 100644 --- a/openVulkanoCpp/Host/GLFW/WindowGLFW.hpp +++ b/openVulkanoCpp/Host/GLFW/WindowGLFW.hpp @@ -23,6 +23,7 @@ namespace OpenVulkano::GLFW InputProviderGLFW& inputProvider; GLFWwindow* window = nullptr; IWindowHandler* handler = nullptr; + Math::Vector2ui currentSize = {}; public: WindowGLFW(InputProviderGLFW& inputProvider);