From cb8e91924399948888d80d20c6112df473897183 Mon Sep 17 00:00:00 2001 From: Chris Hutchinson Date: Sat, 11 Feb 2023 23:10:50 -0500 Subject: [PATCH] Replaced operating system alert dialog with a warning log message, toggled by a project setting. Fixes #73141 --- doc/classes/ProjectSettings.xml | 3 +++ main/main.cpp | 1 + modules/openxr/register_types.cpp | 18 ++++++++++++++---- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/doc/classes/ProjectSettings.xml b/doc/classes/ProjectSettings.xml index 21be5e4beed8..88b8fe82e1ea 100644 --- a/doc/classes/ProjectSettings.xml +++ b/doc/classes/ProjectSettings.xml @@ -2378,6 +2378,9 @@ Specify the default reference space. + + If [code]true[/code], Godot will display an alert modal when OpenXR initialization fails on startup. + If [code]true[/code], OpenXR will manage the depth buffer and use the depth buffer for advanced reprojection provided this is supported by the XR runtime. Note that some rendering features in Godot can't be used with this feature. diff --git a/main/main.cpp b/main/main.cpp index 3aa9a44a21d1..c18c33542ab5 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -1829,6 +1829,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph GLOBAL_DEF_BASIC(PropertyInfo(Variant::INT, "xr/openxr/reference_space", PROPERTY_HINT_ENUM, "Local,Stage"), "1"); GLOBAL_DEF_BASIC("xr/openxr/submit_depth_buffer", false); + GLOBAL_DEF_BASIC("xr/openxr/startup_alert", true); #ifdef TOOLS_ENABLED // Disabled for now, using XR inside of the editor we'll be working on during the coming months. diff --git a/modules/openxr/register_types.cpp b/modules/openxr/register_types.cpp index c39e49387a5e..b7d239fc7379 100644 --- a/modules/openxr/register_types.cpp +++ b/modules/openxr/register_types.cpp @@ -29,6 +29,7 @@ /**************************************************************************/ #include "register_types.h" +#include "core/config/project_settings.h" #include "main/main.h" #include "openxr_interface.h" @@ -113,10 +114,19 @@ void initialize_openxr_module(ModuleInitializationLevel p_level) { ERR_FAIL_NULL(openxr_api); if (!openxr_api->initialize(Main::get_rendering_driver_name())) { - OS::get_singleton()->alert("OpenXR was requested but failed to start.\n" - "Please check if your HMD is connected.\n" - "When using Windows MR please note that WMR only has DirectX support, make sure SteamVR is your default OpenXR runtime.\n" - "Godot will start in normal mode.\n"); + const char *init_error_message = + "OpenXR was requested but failed to start.\n" + "Please check if your HMD is connected.\n" + "When using Windows MR please note that WMR only has DirectX support, make sure SteamVR is your default OpenXR runtime.\n" + "Godot will start in normal mode.\n"; + + WARN_PRINT(init_error_message); + + bool init_show_startup_alert = GLOBAL_GET("xr/openxr/startup_alert"); + if (init_show_startup_alert) { + OS::get_singleton()->alert(init_error_message); + } + memdelete(openxr_api); openxr_api = nullptr; return;