OpenXrContext: Add Windows platform and bindings. (Untested)

This commit is contained in:
Lubosz Sarnecki 2024-03-17 22:43:40 +01:00
parent 7b1bbb6b2d
commit 80c7b8f993

View file

@ -11,9 +11,15 @@
#include <sstream> #include <sstream>
#include <GL/glx.h> #if defined(Q_OS_LINUX)
#include <GL/glx.h>
#define XR_USE_PLATFORM_XLIB
#elif defined(Q_OS_WIN)
#define XR_USE_PLATFORM_WIN32
#else
#error "Unsupported platform"
#endif
#define XR_USE_PLATFORM_XLIB
#define XR_USE_GRAPHICS_API_OPENGL #define XR_USE_GRAPHICS_API_OPENGL
#include <openxr/openxr.h> #include <openxr/openxr.h>
#include <openxr/openxr_platform.h> #include <openxr/openxr_platform.h>
@ -178,14 +184,22 @@ bool OpenXrContext::requestExitSession() {
} }
bool OpenXrContext::initSession() { bool OpenXrContext::initSession() {
// TODO: Make cross platform #if defined(Q_OS_LINUX)
XrGraphicsBindingOpenGLXlibKHR binding = { XrGraphicsBindingOpenGLXlibKHR binding = {
.type = XR_TYPE_GRAPHICS_BINDING_OPENGL_XLIB_KHR, .type = XR_TYPE_GRAPHICS_BINDING_OPENGL_XLIB_KHR,
.xDisplay = XOpenDisplay(nullptr), .xDisplay = XOpenDisplay(nullptr),
.glxDrawable = glXGetCurrentDrawable(), .glxDrawable = glXGetCurrentDrawable(),
.glxContext = glXGetCurrentContext(), .glxContext = glXGetCurrentContext(),
}; };
#elif defined(Q_OS_WIN)
XrGraphicsBindingOpenGLWin32KHR binding = {
.type = XR_TYPE_GRAPHICS_BINDING_OPENGL_XLIB_KHR,
.xDisplay = wglGetCurrentDC(),
.glxContext = wglGetCurrentContext(),
};
#else
#error "Unsupported platform"
#endif
XrSessionCreateInfo info = { XrSessionCreateInfo info = {
.type = XR_TYPE_SESSION_CREATE_INFO, .type = XR_TYPE_SESSION_CREATE_INFO,
.next = &binding, .next = &binding,