aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Stroyan <mike@LunarG.com>2015-10-28 09:46:57 -0600
committerMike Stroyan <mike@LunarG.com>2015-10-28 17:07:07 -0600
commitbb60b383a14170c5476c5ae12957ecf626236916 (patch)
treec2702eeaa710018ddc3de6cf6c2db65c0f0cf160
parent42947aaf5d6f7c28d56ab5c0205757d083a62a6a (diff)
downloadusermoji-bb60b383a14170c5476c5ae12957ecf626236916.tar.xz
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.
-rw-r--r--demos/cube.c10
-rw-r--r--demos/tri.c8
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.
//