Set XR_LOADER_DEBUG environment variable to none;

LOVR doesn't require OpenXR to run.  When the headset module is enabled
and the openxr headset driver is enabled, LOVR tries to initialize
OpenXR, and if it fails then it will try the next driver.

The OpenXR loader will print error messages to stderr by default.  This
is undesirable because someone who is unfamiliar with OpenXR will see a
bunch of messages in their console that say "ERROR" and think something
is wrong, even though the messages are innocuous and don't indicate an
actual problem.

The only way to silence these messages from the OpenXR loader, to my
knowledge, is to set the XR_LOADER_DEBUG environment variable to 'none'.
This is only done when the environment variable isn't set, so it's still
possible to set XR_LOADER_DEBUG to see the logs.
This commit is contained in:
bjorn 2023-07-31 17:21:05 -07:00
parent c38165a154
commit c6cb5451ee
1 changed files with 8 additions and 1 deletions

View File

@ -438,7 +438,8 @@ static void openxr_destroy();
static bool openxr_init(HeadsetConfig* config) {
state.config = *config;
#ifdef __ANDROID__
// Loader
#if defined(__ANDROID__)
static PFN_xrInitializeLoaderKHR xrInitializeLoaderKHR;
XR_LOAD(xrInitializeLoaderKHR);
if (!xrInitializeLoaderKHR) {
@ -454,6 +455,12 @@ static bool openxr_init(HeadsetConfig* config) {
if (XR_FAILED(xrInitializeLoaderKHR((XrLoaderInitInfoBaseHeaderKHR*) &loaderInfo))) {
return false;
}
#elif defined(__linux__) || defined(__APPLE__)
setenv("XR_LOADER_DEBUG", "none", 0);
#elif defined(_WIN32)
if (GetEnvironmentVariable("XR_LOADER_DEBUG", NULL, 0) == 0 && GetLastError() == ERROR_ENVVAR_NOT_FOUND) {
SetEnvironmentVariable("XR_LOADER_DEBUG", "none");
}
#endif
{ // Instance