OpenXr: Platform improvements.

Add missing includes on Windows.
Include GLX only on Linux.

Move openxr_platform.h include to OpenXrContext.h. To make this
possible, certain names from GLX/X11 need to be undefined in order to be
now includable in OpenXrInput.h.

Add Overte e.V. copyright.

Co-authored-by: Lubosz Sarnecki <lubosz@gmail.com>
This commit is contained in:
HifiExperiments 2024-08-09 20:12:12 -07:00 committed by Ada
parent 661fe08f08
commit c8557f5c78
8 changed files with 37 additions and 24 deletions

View file

@ -1,5 +1,6 @@
#
# Copyright 2024 Lubosz Sarnecki
# Copyright 2024 Overte e.V.
#
# SPDX-License-Identifier: Apache-2.0
#

View file

@ -2,6 +2,7 @@
// Overte OpenXR Plugin
//
// Copyright 2024 Lubosz Sarnecki
// Copyright 2024 Overte e.V.
//
// SPDX-License-Identifier: Apache-2.0
//
@ -11,19 +12,6 @@
#include <sstream>
#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_GRAPHICS_API_OPENGL
#include <openxr/openxr.h>
#include <openxr/openxr_platform.h>
Q_DECLARE_LOGGING_CATEGORY(xr_context_cat)
Q_LOGGING_CATEGORY(xr_context_cat, "openxr.context")

View file

@ -2,19 +2,42 @@
// Overte OpenXR Plugin
//
// Copyright 2024 Lubosz Sarnecki
// Copyright 2024 Overte e.V.
//
// SPDX-License-Identifier: Apache-2.0
//
#pragma once
#include "controllers/Pose.h"
#include <openxr/openxr.h>
#include "gpu/gl/GLBackend.h"
#if defined(Q_OS_LINUX)
#define XR_USE_PLATFORM_XLIB
#include <GL/glx.h>
// Unsorted from glx.h conflicts with qdir.h
#undef Unsorted
// MappingPointer from X11 conflicts with one from controllers/Forward.h
#undef MappingPointer
#elif defined(Q_OS_WIN)
#define XR_USE_PLATFORM_WIN32
#include <Unknwn.h>
#include <Windows.h>
#else
#error "Unimplemented platform"
#endif
#define XR_USE_GRAPHICS_API_OPENGL
#include <openxr/openxr_platform.h>
#include <glm/glm.hpp>
#include <glm/gtx/quaternion.hpp>
#include "controllers/Pose.h"
#define HAND_COUNT 2
constexpr XrPosef XR_INDENTITY_POSE = {

View file

@ -2,6 +2,7 @@
// Overte OpenXR Plugin
//
// Copyright 2024 Lubosz Sarnecki
// Copyright 2024 Overte e.V.
//
// SPDX-License-Identifier: Apache-2.0
//
@ -16,6 +17,11 @@
#include <glm/gtx/transform.hpp>
#include <thread>
#if defined(Q_OS_WIN)
#undef near
#undef far
#endif
Q_DECLARE_LOGGING_CATEGORY(xr_display_cat)
Q_LOGGING_CATEGORY(xr_display_cat, "openxr.display")
@ -264,7 +270,7 @@ void OpenXrDisplayPlugin::internalDeactivate() {
// We can get into a state where activate -> deactivate -> activate is called in a chain.
// We are probably gonna have a bad time then. At least check if the session is already running.
// This happens when the application decides to switch display plugins back and forth. This should
// prbably be fixed there.
// probably be fixed there.
if (_context->_isSessionRunning) {
if (!_context->requestExitSession()) {
qCCritical(xr_display_cat, "Failed to request exit session");

View file

@ -2,6 +2,7 @@
// Overte OpenXR Plugin
//
// Copyright 2024 Lubosz Sarnecki
// Copyright 2024 Overte e.V.
//
// SPDX-License-Identifier: Apache-2.0
//
@ -13,15 +14,6 @@
#include "OpenXrContext.h"
#include "gpu/gl/GLBackend.h"
#include <GL/glx.h>
#define XR_USE_PLATFORM_XLIB
#define XR_USE_GRAPHICS_API_OPENGL
#include <openxr/openxr.h>
#include <openxr/openxr_platform.h>
class OpenXrDisplayPlugin : public HmdDisplayPlugin {
public:
OpenXrDisplayPlugin(std::shared_ptr<OpenXrContext> c);

View file

@ -2,6 +2,7 @@
// Overte OpenXR Plugin
//
// Copyright 2024 Lubosz Sarnecki
// Copyright 2024 Overte e.V.
//
// SPDX-License-Identifier: Apache-2.0
//

View file

@ -2,6 +2,7 @@
// Overte OpenXR Plugin
//
// Copyright 2024 Lubosz Sarnecki
// Copyright 2024 Overte e.V.
//
// SPDX-License-Identifier: Apache-2.0
//

View file

@ -2,6 +2,7 @@
// Overte OpenXR Plugin
//
// Copyright 2024 Lubosz Sarnecki
// Copyright 2024 Overte e.V.
//
// SPDX-License-Identifier: Apache-2.0
//