aboutsummaryrefslogtreecommitdiffstats
path: root/src/window.cpp
diff options
context:
space:
mode:
authorladevieq <ladevie.quentin@gmail.com>2021-01-17 20:54:11 +0100
committerladevieq <ladevie.quentin@gmail.com>2021-01-17 20:54:11 +0100
commit25125b2e23c02199bdefb3a638584465229fd833 (patch)
treef52891f855f3cf78f3f97cd5c38fe23e55a0424d /src/window.cpp
parentdfc9a9b37d544d3a357b560829d2a9a48e5e5f5b (diff)
Handle window resize
Diffstat (limited to 'src/window.cpp')
-rw-r--r--src/window.cpp21
1 files changed, 20 insertions, 1 deletions
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);
}