aboutsummaryrefslogtreecommitdiff
path: root/demos/cube.cpp
diff options
context:
space:
mode:
authorTony Barbour <tony@LunarG.com>2016-11-14 14:46:33 -0700
committerTony Barbour <tony@LunarG.com>2016-11-15 13:04:56 -0700
commit78d6b57e312769a82ab3cf115fee6cb5ee709723 (patch)
treec350ae5471cafd18bf9384f3a2d541bd5b136315 /demos/cube.cpp
parent4a2ad6dcb09ace4188fed8bf8e6ee262b678d6e5 (diff)
downloadusermoji-78d6b57e312769a82ab3cf115fee6cb5ee709723.tar.xz
demos: Enable building combinations of xcb and xlib
Change-Id: I055c12e8c93d05db747239df46611386eb8b8278
Diffstat (limited to 'demos/cube.cpp')
-rw-r--r--demos/cube.cpp53
1 files changed, 32 insertions, 21 deletions
diff --git a/demos/cube.cpp b/demos/cube.cpp
index 9fc04c9d..e91b0c3f 100644
--- a/demos/cube.cpp
+++ b/demos/cube.cpp
@@ -212,17 +212,19 @@ struct Demo {
window{nullptr},
minsize(POINT{
0, 0}), // Use explicit construction to avoid MSVC error C2797.
-#elif defined(VK_USE_PLATFORM_XLIB_KHR) || defined(VK_USE_PLATFORM_XCB_KHR)
- display{nullptr},
- xlib_window{0}, xlib_wm_delete_window{0}, connection{nullptr},
- screen{nullptr}, xcb_window{0}, atom_wm_delete_window{nullptr},
-#elif defined(VK_USE_PLATFORM_WAYLAND_KHR)
- display{nullptr},
- registry{nullptr}, compositor{nullptr}, window{nullptr},
- shell{nullptr}, shell_surface{nullptr},
#endif
- prepared{false},
- use_staging_buffer{false}, use_xlib{false},
+#if defined(VK_USE_PLATFORM_XLIB_KHR)
+ xlib_window{0},
+ xlib_wm_delete_window{0}, display{nullptr},
+#endif
+#if defined(VK_USE_PLATFORM_XCB_KHR)
+ xcb_window{0}, screen{nullptr}, connection{nullptr},
+#endif
+#if defined(VK_USE_PLATFORM_WAYLAND_KHR)
+ display{nullptr}, registry{nullptr}, compositor{nullptr},
+ window{nullptr}, shell{nullptr}, shell_surface{nullptr},
+#endif
+ prepared{false}, use_staging_buffer{false}, use_xlib{false},
graphics_queue_family_index{0}, present_queue_family_index{0},
enabled_extension_count{0}, enabled_layer_count{0}, width{0},
height{0}, swapchainImageCount{0}, frame_index{0}, spin_angle{0.0f},
@@ -231,8 +233,6 @@ struct Demo {
suppress_popups{false}, current_buffer{0}, queue_family_count{0} {
#if defined(VK_USE_PLATFORM_WIN32_KHR)
memset(name, '\0', APP_NAME_STR_LEN);
-#elif defined(VK_USE_PLATFORM_XLIB_KHR) || defined(VK_USE_PLATFORM_XCB_KHR)
-#elif defined(VK_USE_PLATFORM_WAYLAND_KHR)
#endif
memset(projection_matrix, 0, sizeof(projection_matrix));
memset(view_matrix, 0, sizeof(view_matrix));
@@ -342,7 +342,7 @@ struct Demo {
inst.destroySurfaceKHR(surface, nullptr);
inst.destroy(nullptr);
-#if defined(VK_USE_PLATFORM_XLIB_KHR) || defined(VK_USE_PLATFORM_XCB_KHR)
+#if defined(VK_USE_PLATFORM_XLIB_KHR) && defined(VK_USE_PLATFORM_XCB_KHR)
if (use_xlib) {
XDestroyWindow(display, xlib_window);
XCloseDisplay(display);
@@ -351,6 +351,13 @@ struct Demo {
xcb_disconnect(connection);
}
free(atom_wm_delete_window);
+#elif defined(VK_USE_PLATFORM_XLIB_KHR)
+ XDestroyWindow(display, xlib_window);
+ XCloseDisplay(display);
+#elif defined(VK_USE_PLATFORM_XCB_KHR)
+ xcb_destroy_window(connection, xcb_window);
+ xcb_disconnect(connection);
+ free(atom_wm_delete_window);
#elif defined(VK_USE_PLATFORM_WAYLAND_KHR)
wl_shell_surface_destroy(shell_surface);
wl_surface_destroy(window);
@@ -2581,16 +2588,19 @@ struct Demo {
HWND window; // hWnd - window handle
POINT minsize; // minimum window size
char name[APP_NAME_STR_LEN]; // Name to put on the window/icon
-#elif defined(VK_USE_PLATFORM_XLIB_KHR) || defined(VK_USE_PLATFORM_XCB_KHR)
- Display *display;
+#endif
+#if defined(VK_USE_PLATFORM_XLIB_KHR)
Window xlib_window;
Atom xlib_wm_delete_window;
-
- xcb_connection_t *connection;
- xcb_screen_t *screen;
+ Display *display;
+#endif
+#if defined(VK_USE_PLATFORM_XCB_KHR)
xcb_window_t xcb_window;
+ xcb_screen_t *screen;
+ xcb_connection_t *connection;
xcb_intern_atom_reply_t *atom_wm_delete_window;
-#elif defined(VK_USE_PLATFORM_WAYLAND_KHR)
+#endif
+#if defined(VK_USE_PLATFORM_WAYLAND_KHR)
wl_display *display;
wl_registry *registry;
wl_compositor *compositor;
@@ -2834,14 +2844,15 @@ int main(int argc, char **argv) {
demo.create_xlib_window();
} else {
demo.create_xcb_window();
+ }
#elif defined(VK_USE_PLATFORM_XCB_KHR)
demo.create_xcb_window();
#elif defined(VK_USE_PLATFORM_XLIB_KHR)
+ demo.use_xlib = true;
demo.create_xlib_window();
#elif defined(VK_USE_PLATFORM_WAYLAND_KHR)
demo.create_window();
#endif
- }
demo.init_vk_swapchain();
@@ -2852,6 +2863,7 @@ int main(int argc, char **argv) {
demo.run_xlib();
} else {
demo.run_xcb();
+ }
#elif defined(VK_USE_PLATFORM_XCB_KHR)
demo.run_xcb();
#elif defined(VK_USE_PLATFORM_XLIB_KHR)
@@ -2859,7 +2871,6 @@ demo.run_xlib();
#elif defined(VK_USE_PLATFORM_WAYLAND_KHR)
demo.run();
#endif
- }
demo.cleanup();