1 | /**************************************************************************/ |
2 | /* openxr_extension_wrapper_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_EXTENSION_WRAPPER_EXTENSION_H |
32 | #define OPENXR_EXTENSION_WRAPPER_EXTENSION_H |
33 | |
34 | #include "../openxr_api_extension.h" |
35 | #include "openxr_extension_wrapper.h" |
36 | |
37 | #include "core/object/ref_counted.h" |
38 | #include "core/os/os.h" |
39 | #include "core/os/thread_safe.h" |
40 | #include "core/variant/native_ptr.h" |
41 | |
42 | class OpenXRExtensionWrapperExtension : public Object, OpenXRExtensionWrapper { |
43 | GDCLASS(OpenXRExtensionWrapperExtension, Object); |
44 | |
45 | protected: |
46 | _THREAD_SAFE_CLASS_ |
47 | |
48 | static void _bind_methods(); |
49 | |
50 | Ref<OpenXRAPIExtension> openxr_api; |
51 | |
52 | public: |
53 | virtual HashMap<String, bool *> get_requested_extensions() override; |
54 | |
55 | GDVIRTUAL0R(Dictionary, _get_requested_extensions); |
56 | |
57 | virtual void *set_system_properties_and_get_next_pointer(void *p_next_pointer) override; |
58 | virtual void *set_instance_create_info_and_get_next_pointer(void *p_next_pointer) override; |
59 | virtual void *set_session_create_and_get_next_pointer(void *p_next_pointer) override; |
60 | virtual void *set_swapchain_create_info_and_get_next_pointer(void *p_next_pointer) override; |
61 | |
62 | //TODO workaround as GDExtensionPtr<void> return type results in build error in godot-cpp |
63 | GDVIRTUAL1R(uint64_t, _set_system_properties_and_get_next_pointer, GDExtensionPtr<void>); |
64 | GDVIRTUAL1R(uint64_t, _set_instance_create_info_and_get_next_pointer, GDExtensionPtr<void>); |
65 | GDVIRTUAL1R(uint64_t, _set_session_create_and_get_next_pointer, GDExtensionPtr<void>); |
66 | GDVIRTUAL1R(uint64_t, _set_swapchain_create_info_and_get_next_pointer, GDExtensionPtr<void>); |
67 | |
68 | virtual void on_register_metadata() override; |
69 | virtual void on_before_instance_created() override; |
70 | virtual void on_instance_created(const XrInstance p_instance) override; |
71 | virtual void on_instance_destroyed() override; |
72 | virtual void on_session_created(const XrSession p_session) override; |
73 | virtual void on_process() override; |
74 | virtual void on_pre_render() override; |
75 | virtual void on_session_destroyed() override; |
76 | |
77 | GDVIRTUAL0(_on_register_metadata); |
78 | GDVIRTUAL0(_on_before_instance_created); |
79 | GDVIRTUAL1(_on_instance_created, uint64_t); |
80 | GDVIRTUAL0(_on_instance_destroyed); |
81 | GDVIRTUAL1(_on_session_created, uint64_t); |
82 | GDVIRTUAL0(_on_process); |
83 | GDVIRTUAL0(_on_pre_render); |
84 | GDVIRTUAL0(_on_session_destroyed); |
85 | |
86 | virtual void on_state_idle() override; |
87 | virtual void on_state_ready() override; |
88 | virtual void on_state_synchronized() override; |
89 | virtual void on_state_visible() override; |
90 | virtual void on_state_focused() override; |
91 | virtual void on_state_stopping() override; |
92 | virtual void on_state_loss_pending() override; |
93 | virtual void on_state_exiting() override; |
94 | |
95 | GDVIRTUAL0(_on_state_idle); |
96 | GDVIRTUAL0(_on_state_ready); |
97 | GDVIRTUAL0(_on_state_synchronized); |
98 | GDVIRTUAL0(_on_state_visible); |
99 | GDVIRTUAL0(_on_state_focused); |
100 | GDVIRTUAL0(_on_state_stopping); |
101 | GDVIRTUAL0(_on_state_loss_pending); |
102 | GDVIRTUAL0(_on_state_exiting); |
103 | |
104 | virtual bool on_event_polled(const XrEventDataBuffer &p_event) override; |
105 | |
106 | GDVIRTUAL1R(bool, _on_event_polled, GDExtensionConstPtr<void>); |
107 | |
108 | Ref<OpenXRAPIExtension> get_openxr_api(); |
109 | |
110 | void register_extension_wrapper(); |
111 | |
112 | OpenXRExtensionWrapperExtension(); |
113 | }; |
114 | |
115 | #endif // OPENXR_EXTENSION_WRAPPER_EXTENSION_H |
116 | |