demos: windows fixes for cube and tri resize
Defer resize until after first prepare.
Record new window size from WM_SIZE.
Leave demo->swapchain.handle valid to pass to CreateSwapchainKHR.
diff --git a/demos/cube.c b/demos/cube.c
index ea53f49..9702299 100644
--- a/demos/cube.c
+++ b/demos/cube.c
@@ -1767,8 +1767,6 @@
.count = 1,
};
- demo->swapchain.handle = VK_NULL_HANDLE;
-
demo_prepare_buffers(demo);
demo_prepare_depth(demo);
demo_prepare_textures(demo);
@@ -1800,7 +1798,7 @@
demo_flush_init_cmd(demo);
demo->current_buffer = 0;
- demo->prepared = true;
+ demo->prepared = true;
}
static void demo_cleanup(struct demo *demo)
@@ -1862,6 +1860,10 @@
{
uint32_t i;
+ // Don't react to resize until after first initialization.
+ if (!demo->prepared) {
+ return;
+ }
// In order to properly resize the window, we must re-create the swapchain
// AND redo the command buffers, etc.
//
@@ -1951,6 +1953,8 @@
demo_run(&demo);
break;
case WM_SIZE:
+ demo.width = lParam & 0xffff;
+ demo.height = lParam & 0xffff0000 >> 16;
demo_resize(&demo);
break;
default: