| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
#pragma once |
| 32 |
|
| 33 |
#include "core/error/error_macros.h" |
| 34 |
#include "core/math/projection.h" |
| 35 |
#include "core/object/class_db.h" |
| 36 |
#include "core/object/gdvirtual.gen.inc" |
| 37 |
#include "core/templates/hash_map.h" |
| 38 |
#include "core/templates/rid.h" |
| 39 |
#include "core/variant/native_ptr.h" |
| 40 |
#include "core/variant/typed_array.h" |
| 41 |
#include "core/variant/variant.h" |
| 42 |
|
| 43 |
#include <openxr/openxr.h> |
| 44 |
|
| 45 |
class OpenXRAPI; |
| 46 |
class OpenXRAPIExtension; |
| 47 |
class OpenXRActionMap; |
| 48 |
|
| 49 |
|
| 50 |
class OpenXRExtensionWrapper : public Object { |
| 51 |
GDCLASS(OpenXRExtensionWrapper, Object); |
| 52 |
|
| 53 |
Ref<OpenXRAPIExtension> _gdextension_get_openxr_api(); |
| 54 |
void _gdextension_register_extension_wrapper(); |
| 55 |
|
| 56 |
protected: |
| 57 |
static void _bind_methods(); |
| 58 |
|
| 59 |
Ref<OpenXRAPIExtension> openxr_api_extension; |
| 60 |
|
| 61 |
public: |
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
virtual HashMap<String, bool *> get_requested_extensions(XrVersion p_xr_version); |
| 70 |
|
| 71 |
GDVIRTUAL1R(Dictionary, _get_requested_extensions, uint64_t); |
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
virtual void *set_system_properties_and_get_next_pointer(void *p_next_pointer); |
| 80 |
virtual void *set_instance_create_info_and_get_next_pointer(XrVersion p_xr_version, void *p_next_pointer); |
| 81 |
virtual void *set_session_create_and_get_next_pointer(void *p_next_pointer); |
| 82 |
virtual void *set_swapchain_create_info_and_get_next_pointer(void *p_next_pointer); |
| 83 |
virtual void *set_hand_joint_locations_and_get_next_pointer(int p_hand_index, void *p_next_pointer); |
| 84 |
virtual void *set_projection_views_and_get_next_pointer(int p_view_index, void *p_next_pointer); |
| 85 |
virtual void *set_reference_space_create_info_and_get_next_pointer(int p_reference_space_type, void *p_next_pointer); |
| 86 |
|
| 87 |
virtual void *set_frame_wait_info_and_get_next_pointer(void *p_next_pointer); |
| 88 |
virtual void *set_view_locate_info_and_get_next_pointer(void *p_next_pointer); |
| 89 |
virtual void *set_frame_end_info_and_get_next_pointer(void *p_next_pointer); |
| 90 |
|
| 91 |
virtual void prepare_view_configuration(uint32_t p_view_count); |
| 92 |
virtual void *set_view_configuration_and_get_next_pointer(uint32_t p_view, void *p_next_pointer); |
| 93 |
virtual void print_view_configuration_info(uint32_t p_view) const; |
| 94 |
|
| 95 |
|
| 96 |
GDVIRTUAL1R(uint64_t, _set_system_properties_and_get_next_pointer, GDExtensionPtr<void>); |
| 97 |
GDVIRTUAL2R(uint64_t, _set_instance_create_info_and_get_next_pointer, uint64_t, GDExtensionPtr<void>); |
| 98 |
GDVIRTUAL1R(uint64_t, _set_session_create_and_get_next_pointer, GDExtensionPtr<void>); |
| 99 |
GDVIRTUAL1R(uint64_t, _set_swapchain_create_info_and_get_next_pointer, GDExtensionPtr<void>); |
| 100 |
GDVIRTUAL2R(uint64_t, _set_hand_joint_locations_and_get_next_pointer, int, GDExtensionPtr<void>); |
| 101 |
GDVIRTUAL2R(uint64_t, _set_projection_views_and_get_next_pointer, int, GDExtensionPtr<void>); |
| 102 |
GDVIRTUAL1R(uint64_t, _set_frame_wait_info_and_get_next_pointer, GDExtensionPtr<void>); |
| 103 |
GDVIRTUAL1R(uint64_t, _set_frame_end_info_and_get_next_pointer, GDExtensionPtr<void>); |
| 104 |
GDVIRTUAL1R(uint64_t, _set_view_locate_info_and_get_next_pointer, GDExtensionPtr<void>); |
| 105 |
GDVIRTUAL2R(uint64_t, _set_reference_space_create_info_and_get_next_pointer, int, GDExtensionPtr<void>); |
| 106 |
GDVIRTUAL0R(int, _get_composition_layer_count); |
| 107 |
GDVIRTUAL1R(uint64_t, _get_composition_layer, int); |
| 108 |
GDVIRTUAL1R(int, _get_composition_layer_order, int); |
| 109 |
GDVIRTUAL1(_prepare_view_configuration, int); |
| 110 |
GDVIRTUAL2R(uint64_t, _set_view_configuration_and_get_next_pointer, uint32_t, GDExtensionPtr<void>); |
| 111 |
GDVIRTUAL1C(_print_view_configuration_info, int); |
| 112 |
|
| 113 |
#ifndef DISABLE_DEPRECATED |
| 114 |
GDVIRTUAL0R_COMPAT(_get_requested_extensions_bind_compat_109302, Dictionary, _get_requested_extensions); |
| 115 |
GDVIRTUAL1R_COMPAT(_set_instance_create_info_and_get_next_pointer_bind_compat_109302, uint64_t, _set_instance_create_info_and_get_next_pointer, GDExtensionPtr<void>); |
| 116 |
#endif |
| 117 |
|
| 118 |
virtual PackedStringArray get_suggested_tracker_names(); |
| 119 |
|
| 120 |
GDVIRTUAL0R(PackedStringArray, _get_suggested_tracker_names); |
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
virtual void on_register_metadata(); |
| 129 |
|
| 130 |
virtual void on_before_instance_created(); |
| 131 |
virtual void on_instance_created(const XrInstance p_instance); |
| 132 |
virtual void on_instance_destroyed(); |
| 133 |
virtual void on_session_created(const XrSession p_session); |
| 134 |
virtual void on_session_destroyed(); |
| 135 |
|
| 136 |
|
| 137 |
|
| 138 |
|
| 139 |
virtual void on_process(); |
| 140 |
virtual void on_sync_actions(); |
| 141 |
virtual void on_pre_render(); |
| 142 |
virtual void on_main_swapchains_created(); |
| 143 |
virtual void on_pre_draw_viewport(RID p_render_target); |
| 144 |
virtual void on_post_draw_viewport(RID p_render_target); |
| 145 |
|
| 146 |
GDVIRTUAL0(_on_register_metadata); |
| 147 |
GDVIRTUAL0(_on_before_instance_created); |
| 148 |
GDVIRTUAL1(_on_instance_created, uint64_t); |
| 149 |
GDVIRTUAL0(_on_instance_destroyed); |
| 150 |
GDVIRTUAL1(_on_session_created, uint64_t); |
| 151 |
GDVIRTUAL0(_on_process); |
| 152 |
GDVIRTUAL0(_on_sync_actions); |
| 153 |
GDVIRTUAL0(_on_pre_render); |
| 154 |
GDVIRTUAL0(_on_main_swapchains_created); |
| 155 |
GDVIRTUAL0(_on_session_destroyed); |
| 156 |
GDVIRTUAL1(_on_pre_draw_viewport, RID); |
| 157 |
GDVIRTUAL1(_on_post_draw_viewport, RID); |
| 158 |
|
| 159 |
virtual void on_state_idle(); |
| 160 |
virtual void on_state_ready(); |
| 161 |
virtual void on_state_synchronized(); |
| 162 |
virtual void on_state_visible(); |
| 163 |
virtual void on_state_focused(); |
| 164 |
virtual void on_state_stopping(); |
| 165 |
virtual void on_state_loss_pending(); |
| 166 |
virtual void on_state_exiting(); |
| 167 |
|
| 168 |
GDVIRTUAL0(_on_state_idle); |
| 169 |
GDVIRTUAL0(_on_state_ready); |
| 170 |
GDVIRTUAL0(_on_state_synchronized); |
| 171 |
GDVIRTUAL0(_on_state_visible); |
| 172 |
GDVIRTUAL0(_on_state_focused); |
| 173 |
GDVIRTUAL0(_on_state_stopping); |
| 174 |
GDVIRTUAL0(_on_state_loss_pending); |
| 175 |
GDVIRTUAL0(_on_state_exiting); |
| 176 |
|
| 177 |
|
| 178 |
virtual int get_composition_layer_count(); |
| 179 |
virtual XrCompositionLayerBaseHeader *get_composition_layer(int p_index); |
| 180 |
virtual int get_composition_layer_order(int p_index); |
| 181 |
|
| 182 |
virtual void *set_viewport_composition_layer_and_get_next_pointer(const XrCompositionLayerBaseHeader *p_layer, const Dictionary &p_property_values, void *p_next_pointer); |
| 183 |
virtual void on_viewport_composition_layer_destroyed(const XrCompositionLayerBaseHeader *p_layer); |
| 184 |
virtual void get_viewport_composition_layer_extension_properties(List<PropertyInfo> *p_property_list); |
| 185 |
virtual Dictionary get_viewport_composition_layer_extension_property_defaults(); |
| 186 |
virtual void *set_android_surface_swapchain_create_info_and_get_next_pointer(const Dictionary &p_property_values, void *p_next_pointer); |
| 187 |
|
| 188 |
GDVIRTUAL3R(uint64_t, _set_viewport_composition_layer_and_get_next_pointer, GDExtensionConstPtr<void>, Dictionary, GDExtensionPtr<void>); |
| 189 |
GDVIRTUAL1(_on_viewport_composition_layer_destroyed, GDExtensionConstPtr<void>); |
| 190 |
GDVIRTUAL0R(TypedArray<Dictionary>, _get_viewport_composition_layer_extension_properties); |
| 191 |
GDVIRTUAL0R(Dictionary, _get_viewport_composition_layer_extension_property_defaults); |
| 192 |
GDVIRTUAL2R(uint64_t, _set_android_surface_swapchain_create_info_and_get_next_pointer, Dictionary, GDExtensionPtr<void>); |
| 193 |
|
| 194 |
|
| 195 |
|
| 196 |
virtual bool on_event_polled(const XrEventDataBuffer &event); |
| 197 |
|
| 198 |
GDVIRTUAL1R(bool, _on_event_polled, GDExtensionConstPtr<void>); |
| 199 |
|
| 200 |
OpenXRExtensionWrapper(); |
| 201 |
virtual ~OpenXRExtensionWrapper() override; |
| 202 |
}; |
| 203 |
|
| 204 |
|
| 205 |
class OpenXRGraphicsExtensionWrapper : public OpenXRExtensionWrapper { |
| 206 |
public: |
| 207 |
virtual void get_usable_swapchain_formats(Vector<int64_t> &p_usable_swap_chains) = 0; |
| 208 |
virtual void get_usable_depth_formats(Vector<int64_t> &p_usable_swap_chains) = 0; |
| 209 |
virtual String get_swapchain_format_name(int64_t p_swapchain_format) const = 0; |
| 210 |
virtual bool get_swapchain_image_data(XrSwapchain p_swapchain, int64_t p_swapchain_format, uint32_t p_width, uint32_t p_height, uint32_t p_sample_count, uint32_t p_array_size, void **r_swapchain_graphics_data) = 0; |
| 211 |
virtual void cleanup_swapchain_graphics_data(void **p_swapchain_graphics_data) = 0; |
| 212 |
virtual bool create_projection_fov(const XrFovf p_fov, double p_z_near, double p_z_far, Projection &r_camera_matrix) = 0; |
| 213 |
virtual RID get_texture(void *p_swapchain_graphics_data, int p_image_index) = 0; |
| 214 |
virtual RID get_density_map(void *p_swapchain_graphics_data, int p_image_index) = 0; |
| 215 |
}; |