OpenXR,如何在 windows、C 和 Vulkan 上获取 xrGetInstanceProcAddr

OpenXR, how to obtain xrGetInstanceProcAddr on windows, C and Vulkan

我需要获取平台特定的 xrGetInstanceProcAddr,我在 windows Visual Studio,语言是 C,API 是 vulkan。

当 运行 以下代码时出现错误“extern undefined symbol xrGetInstanceProcAddr”:

#define XR_USE_PLATFORM_WIN32
#define XR_USE_GRAPHICS_API_VULKAN

#ifdef XR_USE_PLATFORM_WIN32
#include <Windows.h>
#endif

#include "../openxr/openxr.h"
#include "../openxr/openxr_platform.h"
#include "../openxr/openxr_platform_defines.h"
#include "../openxr/openxr_reflection.h"

main(int argc, char** argv)
{
    XrResult result = XR_SUCCESS;
    uint32_t ext_count = 0;

    PFN_xrEnumerateInstanceExtensionProperties qxrEnumerateInstanceExtensionProperties;
    
    result = xrGetInstanceProcAddr(XR_NULL_HANDLE, "xrEnumerateInstanceExtensionProperties", (PFN_xrVoidFunction*)&qxrEnumerateInstanceExtensionProperties);

    result = qxrEnumerateInstanceExtensionProperties(NULL, 0, &ext_count, NULL);
}

需要 openxr 加载器。在 visual studio 中,nuget 包管理器:

Install-Package OpenXR.Loader -Version 1.0.10.2