From 25125b2e23c02199bdefb3a638584465229fd833 Mon Sep 17 00:00:00 2001 From: ladevieq Date: Sun, 17 Jan 2021 20:54:11 +0100 Subject: Handle window resize --- src/window.cpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'src/window.cpp') diff --git a/src/window.cpp b/src/window.cpp index 489473b..7662295 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -1,4 +1,6 @@ #include "window.hpp" +#include "vk-renderer.hpp" +#include "utils.hpp" #ifdef LINUX window::window(uint32_t width, uint32_t height) @@ -87,7 +89,7 @@ window::window(uint32_t width, uint32_t height) void window::poll_events() { MSG msg = {}; - while (PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE)) { + while (PeekMessage(&msg, win_handle, 0, 0, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); } @@ -95,6 +97,23 @@ void window::poll_events() { LRESULT window::message_handler(HWND hwnd, UINT umsg, WPARAM wparam, LPARAM lparam) { switch(umsg) { + case WM_QUIT: { + isOpen = false; + break; + } + case WM_SIZE: { + RECT rect; + if(GetWindowRect(hwnd, &rect)) + { + width = rect.right - rect.left; + height = rect.bottom - rect.top; + } + + if (renderer != nullptr) { + renderer->recreate_swapchain(); + break; + } + } default: return DefWindowProc(hwnd, umsg, wparam, lparam); } -- cgit v1.3