summaryrefslogtreecommitdiff
path: root/modules/openxr/extensions/openxr_opengl_extension.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'modules/openxr/extensions/openxr_opengl_extension.cpp')
-rw-r--r--modules/openxr/extensions/openxr_opengl_extension.cpp85
1 files changed, 41 insertions, 44 deletions
diff --git a/modules/openxr/extensions/openxr_opengl_extension.cpp b/modules/openxr/extensions/openxr_opengl_extension.cpp
index 3b7c130149..cd371b9ed9 100644
--- a/modules/openxr/extensions/openxr_opengl_extension.cpp
+++ b/modules/openxr/extensions/openxr_opengl_extension.cpp
@@ -1,32 +1,32 @@
-/*************************************************************************/
-/* openxr_opengl_extension.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
+/**************************************************************************/
+/* openxr_opengl_extension.cpp */
+/**************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/**************************************************************************/
+/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
+/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/**************************************************************************/
#ifdef GLES3_ENABLED
@@ -37,24 +37,21 @@
#include "servers/rendering/rendering_server_globals.h"
#include "servers/rendering_server.h"
-OpenXROpenGLExtension::OpenXROpenGLExtension(OpenXRAPI *p_openxr_api) :
- OpenXRGraphicsExtensionWrapper(p_openxr_api) {
+HashMap<String, bool *> OpenXROpenGLExtension::get_requested_extensions() {
+ HashMap<String, bool *> request_extensions;
+
#ifdef ANDROID_ENABLED
request_extensions[XR_KHR_OPENGL_ES_ENABLE_EXTENSION_NAME] = nullptr;
#else
request_extensions[XR_KHR_OPENGL_ENABLE_EXTENSION_NAME] = nullptr;
#endif
- ERR_FAIL_NULL(openxr_api);
-}
-
-OpenXROpenGLExtension::~OpenXROpenGLExtension() {
+ return request_extensions;
}
void OpenXROpenGLExtension::on_instance_created(const XrInstance p_instance) {
- ERR_FAIL_NULL(openxr_api);
-
// Obtain pointers to functions we're accessing here.
+ ERR_FAIL_NULL(OpenXRAPI::get_singleton());
#ifdef ANDROID_ENABLED
EXT_INIT_XR_FUNC(xrGetOpenGLESGraphicsRequirementsKHR);
@@ -65,10 +62,10 @@ void OpenXROpenGLExtension::on_instance_created(const XrInstance p_instance) {
}
bool OpenXROpenGLExtension::check_graphics_api_support(XrVersion p_desired_version) {
- ERR_FAIL_NULL_V(openxr_api, false);
+ ERR_FAIL_NULL_V(OpenXRAPI::get_singleton(), false);
- XrSystemId system_id = openxr_api->get_system_id();
- XrInstance instance = openxr_api->get_instance();
+ XrSystemId system_id = OpenXRAPI::get_singleton()->get_system_id();
+ XrInstance instance = OpenXRAPI::get_singleton()->get_instance();
#ifdef ANDROID_ENABLED
XrGraphicsRequirementsOpenGLESKHR opengl_requirements;
@@ -76,7 +73,7 @@ bool OpenXROpenGLExtension::check_graphics_api_support(XrVersion p_desired_versi
opengl_requirements.next = nullptr;
XrResult result = xrGetOpenGLESGraphicsRequirementsKHR(instance, system_id, &opengl_requirements);
- if (!openxr_api->xr_result(result, "Failed to get OpenGL graphics requirements!")) {
+ if (!OpenXRAPI::get_singleton()->xr_result(result, "Failed to get OpenGL graphics requirements!")) {
return false;
}
#else
@@ -85,7 +82,7 @@ bool OpenXROpenGLExtension::check_graphics_api_support(XrVersion p_desired_versi
opengl_requirements.next = nullptr;
XrResult result = xrGetOpenGLGraphicsRequirementsKHR(instance, system_id, &opengl_requirements);
- if (!openxr_api->xr_result(result, "Failed to get OpenGL graphics requirements!")) {
+ if (!OpenXRAPI::get_singleton()->xr_result(result, "Failed to get OpenGL graphics requirements!")) {
return false;
}
#endif
@@ -177,7 +174,7 @@ bool OpenXROpenGLExtension::get_swapchain_image_data(XrSwapchain p_swapchain, in
uint32_t swapchain_length;
XrResult result = xrEnumerateSwapchainImages(p_swapchain, 0, &swapchain_length, nullptr);
if (XR_FAILED(result)) {
- print_line("OpenXR: Failed to get swapchaim image count [", openxr_api->get_error_string(result), "]");
+ print_line("OpenXR: Failed to get swapchaim image count [", OpenXRAPI::get_singleton()->get_error_string(result), "]");
return false;
}
@@ -200,7 +197,7 @@ bool OpenXROpenGLExtension::get_swapchain_image_data(XrSwapchain p_swapchain, in
result = xrEnumerateSwapchainImages(p_swapchain, swapchain_length, &swapchain_length, (XrSwapchainImageBaseHeader *)images);
if (XR_FAILED(result)) {
- print_line("OpenXR: Failed to get swapchaim images [", openxr_api->get_error_string(result), "]");
+ print_line("OpenXR: Failed to get swapchaim images [", OpenXRAPI::get_singleton()->get_error_string(result), "]");
memfree(images);
return false;
}