aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Weiblen <mikew@lunarg.com>2018-02-13 13:56:13 -0700
committerMike Weiblen <mikew@lunarg.com>2018-02-19 12:03:24 -0700
commit5d2ad545981d93a980a066e03aa46725a398518b (patch)
tree6a21d37cd40a6278422264b19ff0c75b17b833ef
parent038151eb9327f271f4aeb2918a78402648ed3f1f (diff)
downloadusermoji-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
-rw-r--r--demos/cube.c13
-rw-r--r--demos/cube.cpp14
2 files changed, 27 insertions, 0 deletions
diff --git a/demos/cube.c b/demos/cube.c
index e5b10b05..5fb79c9a 100644
--- a/demos/cube.c
+++ b/demos/cube.c
@@ -2504,6 +2504,12 @@ static void demo_create_window(struct demo *demo) {
}
#elif defined(VK_USE_PLATFORM_XLIB_KHR)
static void demo_create_xlib_window(struct demo *demo) {
+ const char *display_envar = getenv("DISPLAY");
+ if (display_envar == NULL || display_envar[0] == '\0') {
+ printf("Environment variable DISPLAY requires a valid value.\nExiting ...\n");
+ fflush(stdout);
+ exit(1);
+ }
XInitThreads();
demo->display = XOpenDisplay(NULL);
@@ -3764,6 +3770,13 @@ static void demo_init_connection(struct demo *demo) {
xcb_screen_iterator_t iter;
int scr;
+ const char *display_envar = getenv("DISPLAY");
+ if (display_envar == NULL || display_envar[0] == '\0') {
+ printf("Environment variable DISPLAY requires a valid value.\nExiting ...\n");
+ fflush(stdout);
+ exit(1);
+ }
+
demo->connection = xcb_connect(NULL, &scr);
if (xcb_connection_has_error(demo->connection) > 0) {
printf("Cannot find a compatible Vulkan installable client driver "
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;