From 5d2ad545981d93a980a066e03aa46725a398518b Mon Sep 17 00:00:00 2001 From: Mike Weiblen Date: Tue, 13 Feb 2018 13:56:13 -0700 Subject: demos: ensure DISPLAY envar is valid If the DISPLAY environment variable is unset or null, the cube demo will emit "Cannot find a compatible Vulkan installable client driver (ICD)." That message is not helpful when attempting to resolve the issue, since the problem is with the envar, not the ICD. Change-Id: Idf145cf0da906a4a8352b5bb136f88d9c1bca90d --- demos/cube.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'demos/cube.cpp') diff --git a/demos/cube.cpp b/demos/cube.cpp index 1cd32052..f436cd56 100644 --- a/demos/cube.cpp +++ b/demos/cube.cpp @@ -971,6 +971,13 @@ Demo::Demo() xcb_screen_iterator_t iter; int scr; + const char *display_envar = getenv("DISPLAY"); + if (display_envar == nullptr || display_envar[0] == '\0') { + printf("Environment variable DISPLAY requires a valid value.\nExiting ...\n"); + fflush(stdout); + exit(1); + } + connection = xcb_connect(nullptr, &scr); if (xcb_connection_has_error(connection) > 0) { printf( @@ -2438,6 +2445,13 @@ Demo::Demo() #elif defined(VK_USE_PLATFORM_XLIB_KHR) void Demo::create_xlib_window() { + const char *display_envar = getenv("DISPLAY"); + if (display_envar == nullptr || display_envar[0] == '\0') { + printf("Environment variable DISPLAY requires a valid value.\nExiting ...\n"); + fflush(stdout); + exit(1); + } + XInitThreads(); display = XOpenDisplay(nullptr); long visualMask = VisualScreenMask; -- cgit v1.2.3