diff options
author | Max Argus <argus.max@gmail.com> | 2019-03-27 15:52:50 +0100 |
---|---|---|
committer | Max Argus <argus.max@gmail.com> | 2021-10-22 09:26:59 +0200 |
commit | 3c4cb801571492d8bcac40fcadee747d25254ac4 (patch) | |
tree | 03dc2444bc14e5212ce7b0744aa5f11f7f0e0599 | |
parent | 48dc1c45da685c77d3642545c4851b05fb3a1e8b (diff) | |
download | bullet3-3c4cb801571492d8bcac40fcadee747d25254ac4.tar.gz |
EGL device selection by env param.
-rw-r--r-- | examples/OpenGLWindow/EGLOpenGLWindow.cpp | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/examples/OpenGLWindow/EGLOpenGLWindow.cpp b/examples/OpenGLWindow/EGLOpenGLWindow.cpp index f8918f318..52fc66c7f 100644 --- a/examples/OpenGLWindow/EGLOpenGLWindow.cpp +++ b/examples/OpenGLWindow/EGLOpenGLWindow.cpp @@ -33,6 +33,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <cstdlib> #include "OpenGLInclude.h" @@ -124,6 +125,28 @@ void EGLOpenGLWindow::createWindow(const b3gWindowConstructionInfo& ci) { printf("eglQueryDevicesEXT Failed.\n"); m_data->egl_display = EGL_NO_DISPLAY; + } else + { + // default case, should always happen (for future compatibility) + if (m_data->m_renderDevice == -1) + { + // check env variable + const char* env_p = std::getenv("EGL_VISIBLE_DEVICES"); + + // variable is set + if(env_p != NULL) + { + m_data->m_renderDevice = std::atoi(env_p); + fprintf(stderr, "EGL device choice: %d of %d (from EGL_VISIBLE_DEVICES)\n", m_data->m_renderDevice, num_devices); + + } else { + fprintf(stderr, "EGL device choice: %d of %d.\n", m_data->m_renderDevice, num_devices); + } // else leave with -1 + + } else + { + fprintf(stderr, "EGL device choice: %d of %d.\n", m_data->m_renderDevice, num_devices); + } } // Query EGL Screens if (m_data->m_renderDevice == -1) @@ -179,7 +202,7 @@ void EGLOpenGLWindow::createWindow(const b3gWindowConstructionInfo& ci) if (!eglInitialize(m_data->egl_display, NULL, NULL)) { - fprintf(stderr, "Unable to initialize EGL\n"); + fprintf(stderr, "eglInitialize() failed with error: %x\n", eglGetError()); exit(EXIT_FAILURE); } |