Hi.
I create my own application to interact with VR and can you help me with it, pls? When I try to get system id, I get error code -2 (with your app the same behavior).
Maybe, you know how to fix it? Thx, in advance!
Verbose [GENERAL | xrCreateInstance | OpenXR-Loader] : Entering loader trampoline
Info [GENERAL | | OpenXR-Loader] : RuntimeManifestFile::FindManifestFiles - using registry-specified runtime file C:\My\Steam\steamapps\common\SteamVR\steamxr_win64.json
Info [GENERAL | | OpenXR-Loader] : RuntimeManifestFile::CreateIfValid - attempting to load C:\My\Steam\steamapps\common\SteamVR\steamxr_win64.json
Info [GENERAL | xrCreateInstance | OpenXR-Loader] : RuntimeInterface::LoadRuntime succeeded loading runtime defined in manifest file C:\My\Steam\steamapps\common\SteamVR\steamxr_win64.json using interface version 1 and OpenXR API version 1.0
Info [GENERAL | xrCreateInstance | OpenXR-Loader] : ApiLayerInterface::LoadApiLayers succeeded loading layer XR_APILAYER_MBUCCHIA_toolkit using interface version 1 and OpenXR API version 1.0
Info [GENERAL | xrCreateInstance | OpenXR-Loader] : ApiLayerInterface::LoadApiLayers succeeded loading layer XR_APILAYER_LUNARG_core_validation using interface version 1 and OpenXR API version 1.0
Verbose [GENERAL | xrCreateInstance | OpenXR-Loader] : Entering LoaderInstance::CreateInstance
Core Validation output type: text, first time = true
Verbose [GENERAL | xrCreateInstance | OpenXR-Loader] : Entering loader terminator
Verbose [GENERAL | xrCreateInstance | OpenXR-Loader] : Completed loader terminator
Verbose [GENERAL | xrDestroyInstance | OpenXR-Loader] : Entering loader terminator
Verbose [GENERAL | xrDestroyInstance | OpenXR-Loader] : Completed loader terminator
Core Validation output type: text, first time = false
Verbose [GENERAL | xrCreateInstance | OpenXR-Loader] : Entering loader terminator
Verbose [GENERAL | xrCreateInstance | OpenXR-Loader] : Completed loader terminator
Info [GENERAL | xrCreateInstance | OpenXR-Loader] : LoaderInstance::CreateInstance succeeded with 2 layers enabled and runtime interface - created instance = 0x00000296268fa580
Verbose [GENERAL | xrCreateInstance | OpenXR-Loader] : Completed loader trampoline
[VALID_ERROR | VUID-XrSystemProperties-next-next | xrGetSystemProperties]: Invalid structure(s) in "next" chain for XrSystemProperties struct "next"
Objects:
[0] - XrInstance (0x00000296268fa580)
[VALID_ERROR | VUID-xrGetSystemProperties-properties-parameter | xrGetSystemProperties]: Command xrGetSystemProperties param properties is invalid
Objects:
[0] - XrInstance (0x00000296268fa580)
Error: Failed to get system: -2
XrInstance createInstance(std::string_view appName)
{
static const char *const layerNames[]{"XR_APILAYER_LUNARG_core_validation"};
static const char *const extensionNames[]{
"XR_KHR_vulkan_enable",
"XR_KHR_vulkan_enable2",
// "XR_EXT_hand_tracking",
#ifdef VR_GLOVES_DEBUG_MODE
"XR_EXT_debug_utils"
#endif // VR_GLOVES_DEBUG_MODE
};
XrInstanceCreateInfo instanceCreateInfo{};
instanceCreateInfo.type = XR_TYPE_INSTANCE_CREATE_INFO;
instanceCreateInfo.createFlags = 0;
::strncpy(instanceCreateInfo.applicationInfo.applicationName, appName.data(),
sizeof(instanceCreateInfo.applicationInfo.applicationName));
instanceCreateInfo.applicationInfo.applicationVersion =
XR_MAKE_VERSION(config::appVerMajor,
config::appVerMinor,
config::appVerPatch);
::strncpy(instanceCreateInfo.applicationInfo.engineName, appName.data(),
sizeof(instanceCreateInfo.applicationInfo.engineName));
instanceCreateInfo.applicationInfo.engineVersion =
XR_MAKE_VERSION(config::appVerMajor,
config::appVerMinor,
config::appVerPatch);
instanceCreateInfo.applicationInfo.apiVersion = XR_CURRENT_API_VERSION;
instanceCreateInfo.enabledApiLayerCount = sizeof(layerNames) / sizeof(const char *);
instanceCreateInfo.enabledApiLayerNames = layerNames;
instanceCreateInfo.enabledExtensionCount = sizeof(extensionNames) / sizeof(const char *);
instanceCreateInfo.enabledExtensionNames = extensionNames;
XrInstance instance{XR_NULL_HANDLE};
if (const XrResult result = ::xrCreateInstance(&instanceCreateInfo, &instance);
result != XR_SUCCESS)
{
logger::log_error("Failed to create OpenXR instance: {}", result);
return;
}
return instance;
}
XrSystemId getSystem(XrInstance instance)
{
XrSystemGetInfo systemGetInfo{};
systemGetInfo.type = XR_TYPE_SYSTEM_GET_INFO;
systemGetInfo.formFactor = XR_FORM_FACTOR_HEAD_MOUNTED_DISPLAY;
XrSystemId systemID;
if (const XrResult result = ::xrGetSystem(instance, &systemGetInfo, &systemID);
result != XR_SUCCESS)
{
logger::log_error("Failed to get system: {}", result);
return XR_NULL_SYSTEM_ID;
}
return systemID;
}