From 140f5a6a5adee2b1e5103332a6fc137fca82d1ec Mon Sep 17 00:00:00 2001 From: Bastiaan Olij Date: Wed, 19 Jul 2023 00:02:47 +1000 Subject: [PATCH] Compile OpenXR into MacOS build (cherry picked from commit a9c8feeba00906c4df5f85dc6efaf1ece608cd6b) --- modules/openxr/SCsub | 7 ++++++- modules/openxr/config.py | 2 +- modules/openxr/openxr_api.cpp | 6 +++--- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/modules/openxr/SCsub b/modules/openxr/SCsub index 53faa65e97b..036fdcf1198 100644 --- a/modules/openxr/SCsub +++ b/modules/openxr/SCsub @@ -28,6 +28,11 @@ elif env["platform"] == "linuxbsd": env_openxr.AppendUnique(CPPDEFINES=["HAVE_SECURE_GETENV"]) elif env["platform"] == "windows": env_openxr.AppendUnique(CPPDEFINES=["XR_OS_WINDOWS", "NOMINMAX", "XR_USE_PLATFORM_WIN32"]) +elif env["platform"] == "macos": + env_openxr.AppendUnique(CPPDEFINES=["XR_OS_APPLE"]) + + # There does not seem to be a XR_USE_PLATFORM_XYZ for Apple + # may need to check and set: # - XR_USE_TIMESPEC @@ -96,7 +101,7 @@ if env["platform"] == "android": env_openxr.add_source_files(module_obj, "extensions/openxr_android_extension.cpp") if env["vulkan"]: env_openxr.add_source_files(module_obj, "extensions/openxr_vulkan_extension.cpp") -if env["opengl3"]: +if env["opengl3"] and env["platform"] != "macos": env_openxr.add_source_files(module_obj, "extensions/openxr_opengl_extension.cpp") env_openxr.add_source_files(module_obj, "extensions/openxr_palm_pose_extension.cpp") diff --git a/modules/openxr/config.py b/modules/openxr/config.py index 7d0653ba7e7..92aaf06fcea 100644 --- a/modules/openxr/config.py +++ b/modules/openxr/config.py @@ -1,5 +1,5 @@ def can_build(env, platform): - if platform in ("linuxbsd", "windows", "android"): + if platform in ("linuxbsd", "windows", "android", "macos"): return env["openxr"] and not env["disable_3d"] else: # not supported on these platforms diff --git a/modules/openxr/openxr_api.cpp b/modules/openxr/openxr_api.cpp index 458ee007876..eb9e31cff7a 100644 --- a/modules/openxr/openxr_api.cpp +++ b/modules/openxr/openxr_api.cpp @@ -47,7 +47,7 @@ #ifdef VULKAN_ENABLED #define XR_USE_GRAPHICS_API_VULKAN #endif -#ifdef GLES3_ENABLED +#if defined(GLES3_ENABLED) && !defined(MACOS_ENABLED) #ifdef ANDROID_ENABLED #define XR_USE_GRAPHICS_API_OPENGL_ES #include @@ -72,7 +72,7 @@ #include "extensions/openxr_vulkan_extension.h" #endif -#ifdef GLES3_ENABLED +#if defined(GLES3_ENABLED) && !defined(MACOS_ENABLED) #include "extensions/openxr_opengl_extension.h" #endif @@ -1306,7 +1306,7 @@ bool OpenXRAPI::initialize(const String &p_rendering_driver) { ERR_FAIL_V(false); #endif } else if (p_rendering_driver == "opengl3") { -#ifdef GLES3_ENABLED +#if defined(GLES3_ENABLED) && !defined(MACOS_ENABLED) graphics_extension = memnew(OpenXROpenGLExtension); register_extension_wrapper(graphics_extension); #else