cube: Fill in pPlatformWindow after you have a window
demo_init_vk(), which sets the surface_description.pPlatformWindow was
getting called before the window was created so surface_description.pPlatformWindow
was always NULL. I added a new demo_init_vk_wsi() which splits demo_init_vk()
in two so that the window is created before surface_description.pPlatformWindow is assigned.
diff --git a/demos/cube.c b/demos/cube.c
index ad49f9d..3b41804 100644
--- a/demos/cube.c
+++ b/demos/cube.c
@@ -2383,9 +2383,15 @@
assert(demo->queue_count >= 1);
demo->queue_props = (VkPhysicalDeviceQueueProperties *) malloc(demo->queue_count * sizeof(VkPhysicalDeviceQueueProperties));
- err = vkGetPhysicalDeviceQueueProperties(demo->gpu, queue_count, demo->queue_props);
+ err = vkGetPhysicalDeviceQueueProperties(demo->gpu, demo->queue_count, demo->queue_props);
assert(!err);
- assert(queue_count >= 1);
+ assert(demo->queue_count >= 1);
+}
+
+static void demo_init_vk_wsi(struct demo *demo)
+{
+ VkResult err;
+ uint32_t i;
// Construct the WSI surface description:
demo->surface_description.sType = VK_STRUCTURE_TYPE_SURFACE_DESCRIPTION_WINDOW_WSI;
@@ -2598,6 +2604,7 @@
demo.connection = hInstance;
strncpy(demo.name, "cube", APP_NAME_STR_LEN);
demo_create_window(&demo);
+ demo_init_vk_wsi(&demo);
demo_prepare(&demo);
@@ -2629,6 +2636,7 @@
demo_init(&demo, argc, argv);
demo_create_window(&demo);
+ demo_init_vk_wsi(&demo);
demo_prepare(&demo);
demo_run(&demo);