Fix window resizing issue

This commit is contained in:
Georg Hagen
2024-07-21 21:49:24 +02:00
parent 23df296610
commit 01c273d2fe
2 changed files with 10 additions and 5 deletions

View File

@@ -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<int*>(&currentSize.x), reinterpret_cast<int*>(&currentSize.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);
}

View File

@@ -23,6 +23,7 @@ namespace OpenVulkano::GLFW
InputProviderGLFW& inputProvider;
GLFWwindow* window = nullptr;
IWindowHandler* handler = nullptr;
Math::Vector2ui currentSize = {};
public:
WindowGLFW(InputProviderGLFW& inputProvider);