1/**************************************************************************/
2/* openxr_api_extension.h */
3/**************************************************************************/
4/* This file is part of: */
5/* GODOT ENGINE */
6/* https://godotengine.org */
7/**************************************************************************/
8/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
9/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
10/* */
11/* Permission is hereby granted, free of charge, to any person obtaining */
12/* a copy of this software and associated documentation files (the */
13/* "Software"), to deal in the Software without restriction, including */
14/* without limitation the rights to use, copy, modify, merge, publish, */
15/* distribute, sublicense, and/or sell copies of the Software, and to */
16/* permit persons to whom the Software is furnished to do so, subject to */
17/* the following conditions: */
18/* */
19/* The above copyright notice and this permission notice shall be */
20/* included in all copies or substantial portions of the Software. */
21/* */
22/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
23/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
24/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
25/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
26/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
27/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
28/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
29/**************************************************************************/
30
31#ifndef OPENXR_API_EXTENSION_H
32#define OPENXR_API_EXTENSION_H
33
34#include "openxr_api.h"
35
36#include "core/object/ref_counted.h"
37#include "core/os/os.h"
38#include "core/os/thread_safe.h"
39#include "core/variant/native_ptr.h"
40
41class OpenXRAPIExtension : public RefCounted {
42 GDCLASS(OpenXRAPIExtension, RefCounted);
43
44protected:
45 _THREAD_SAFE_CLASS_
46
47 static void _bind_methods();
48
49public:
50 uint64_t get_instance();
51 uint64_t get_system_id();
52 uint64_t get_session();
53
54 // Helper method to convert an XrPosef to a Transform3D.
55 Transform3D transform_from_pose(GDExtensionConstPtr<const void> p_pose);
56
57 bool xr_result(uint64_t result, String format, Array args = Array());
58
59 static bool openxr_is_enabled(bool p_check_run_in_editor = true);
60
61 //TODO workaround as GDExtensionPtr<void> return type results in build error in godot-cpp
62 uint64_t get_instance_proc_addr(String p_name);
63 String get_error_string(uint64_t result);
64 String get_swapchain_format_name(int64_t p_swapchain_format);
65
66 bool is_initialized();
67 bool is_running();
68
69 uint64_t get_play_space();
70 int64_t get_next_frame_time();
71 bool can_render();
72
73 OpenXRAPIExtension();
74};
75
76#endif // OPENXR_API_EXTENSION_H
77