aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTony Barbour <tony@LunarG.com>2016-08-08 11:04:17 -0600
committerTony Barbour <tony@LunarG.com>2016-08-08 11:37:19 -0600
commit8295ac4a9c90ef9388e0d2902e514903d9f9ce26 (patch)
tree4548520de19ec80ded94fd8b77aed399adaa20cf
parent69c8a784156cd134d6e7e190ed177e297d879219 (diff)
downloadusermoji-8295ac4a9c90ef9388e0d2902e514903d9f9ce26.tar.xz
demos: Fix ifdefs to allow compilation without XLIB
Change-Id: I3fbed70e842bf327437d77f56cd0fa7848ab5d19
-rw-r--r--demos/cube.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/demos/cube.c b/demos/cube.c
index 0760c2dc..a62a7e8a 100644
--- a/demos/cube.c
+++ b/demos/cube.c
@@ -2051,7 +2051,7 @@ static void demo_create_window(struct demo *demo) {
demo->minsize.x = GetSystemMetrics(SM_CXMINTRACK);
demo->minsize.y = GetSystemMetrics(SM_CYMINTRACK)+1;
}
-#elif defined(VK_USE_PLATFORM_XLIB_KHR) | defined(VK_USE_PLATFORM_XCB_KHR)
+#elif defined(VK_USE_PLATFORM_XLIB_KHR)
static void demo_create_xlib_window(struct demo *demo) {
demo->display = XOpenDisplay(NULL);
@@ -2143,7 +2143,8 @@ static void demo_run_xlib(struct demo *demo) {
demo->quit = true;
}
}
-
+#endif // VK_USE_PLATFORM_XLIB_KHR
+#ifdef VK_USE_PLATFORM_XCB_KHR
static void demo_handle_xcb_event(struct demo *demo,
const xcb_generic_event_t *event) {
uint8_t event_code = event->response_type & 0x7f;
@@ -2254,7 +2255,8 @@ static void demo_create_xcb_window(struct demo *demo) {
xcb_configure_window(demo->connection, demo->xcb_window,
XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y, coords);
}
-#elif defined(VK_USE_PLATFORM_WAYLAND_KHR)
+#endif // VK_USE_PLATFORM_XCB_KHR
+#if defined(VK_USE_PLATFORM_WAYLAND_KHR)
static void demo_run(struct demo *demo) {
while (!demo->quit) {
demo_update_data_buffer(demo);
@@ -2995,10 +2997,12 @@ static void demo_init(struct demo *demo, int argc, char **argv) {
demo->validate = true;
continue;
}
+#if defined(VK_USE_PLATFORM_XLIB_KHR)
if (strcmp(argv[i], "--xlib") == 0) {
demo->use_xlib = true;
continue;
}
+#endif
if (strcmp(argv[i], "--c") == 0 && demo->frameCount == INT32_MAX &&
i < argc - 1 && sscanf(argv[i + 1], "%d", &demo->frameCount) == 1 &&
demo->frameCount >= 0) {
@@ -3011,6 +3015,9 @@ static void demo_init(struct demo *demo, int argc, char **argv) {
}
fprintf(stderr, "Usage:\n %s [--use_staging] [--validate] [--break] "
+#if defined(VK_USE_PLATFORM_XLIB_KHR)
+ "[--xlib] "
+#endif
"[--c <framecount>] [--suppress_popups]\n",
APP_SHORT_NAME);
fflush(stderr);
@@ -3202,11 +3209,15 @@ int main(int argc, char **argv) {
struct demo demo;
demo_init(&demo, argc, argv);
-#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 (demo.use_xlib)
demo_create_xlib_window(&demo);
else
demo_create_xcb_window(&demo);
+#elif defined(VK_USE_PLATFORM_XCB_KHR)
+ demo_create_xcb_window(&demo);
+#elif defined(VK_USE_PLATFORM_XLIB_KHR)
+ demo_create_xlib_window(&demo);
#elif defined(VK_USE_PLATFORM_WAYLAND_KHR)
demo_create_window(&demo);
#endif
@@ -3215,11 +3226,15 @@ int main(int argc, char **argv) {
demo_prepare(&demo);
-#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 (demo.use_xlib)
demo_run_xlib(&demo);
else
demo_run_xcb(&demo);
+#elif defined(VK_USE_PLATFORM_XCB_KHR)
+ demo_run_xcb(&demo);
+#elif defined(VK_USE_PLATFORM_XLIB_KHR)
+ demo_run_xlib(&demo);
#elif defined(VK_USE_PLATFORM_WAYLAND_KHR)
demo_run(&demo);
#endif