diff options
| author | Mike Weiblen <mikew@lunarg.com> | 2018-02-13 13:56:13 -0700 |
|---|---|---|
| committer | Mike Weiblen <mikew@lunarg.com> | 2018-02-19 12:03:24 -0700 |
| commit | 5d2ad545981d93a980a066e03aa46725a398518b (patch) | |
| tree | 6a21d37cd40a6278422264b19ff0c75b17b833ef /demos/cube.cpp | |
| parent | 038151eb9327f271f4aeb2918a78402648ed3f1f (diff) | |
| download | usermoji-5d2ad545981d93a980a066e03aa46725a398518b.tar.xz | |
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
Diffstat (limited to 'demos/cube.cpp')
| -rw-r--r-- | demos/cube.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
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; |
