From bb60b383a14170c5476c5ae12957ecf626236916 Mon Sep 17 00:00:00 2001 From: Mike Stroyan Date: Wed, 28 Oct 2015 09:46:57 -0600 Subject: 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. --- demos/cube.c | 10 +++++++--- demos/tri.c | 8 ++++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/demos/cube.c b/demos/cube.c index ea53f496..97022999 100644 --- a/demos/cube.c +++ b/demos/cube.c @@ -1767,8 +1767,6 @@ static void demo_prepare(struct demo *demo) .count = 1, }; - demo->swapchain.handle = VK_NULL_HANDLE; - demo_prepare_buffers(demo); demo_prepare_depth(demo); demo_prepare_textures(demo); @@ -1800,7 +1798,7 @@ static void demo_prepare(struct demo *demo) 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 @@ static void demo_resize(struct demo *demo) { 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 @@ LRESULT CALLBACK WndProc(HWND hWnd, demo_run(&demo); break; case WM_SIZE: + demo.width = lParam & 0xffff; + demo.height = lParam & 0xffff0000 >> 16; demo_resize(&demo); break; default: diff --git a/demos/tri.c b/demos/tri.c index 9bd83d8a..7d34649b 100644 --- a/demos/tri.c +++ b/demos/tri.c @@ -1513,8 +1513,6 @@ static void demo_prepare(struct demo *demo) err = vkAllocCommandBuffers(demo->device, &cmd, &demo->draw_cmd); assert(!err); - demo->swapchain.handle = VK_NULL_HANDLE; - demo_prepare_buffers(demo); demo_prepare_depth(demo); demo_prepare_textures(demo); @@ -1570,6 +1568,8 @@ LRESULT CALLBACK WndProc(HWND hWnd, break; } case WM_SIZE: + demo.width = lParam & 0xffff; + demo.height = lParam & 0xffff0000 >> 16; demo_resize(&demo); break; default: @@ -2257,6 +2257,10 @@ static void demo_resize(struct demo *demo) { 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. // -- cgit v1.2.3