openxr_extension_wrapper_extension.h 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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. #ifndef OPENXR_EXTENSION_WRAPPER_EXTENSION_H
  31. #define OPENXR_EXTENSION_WRAPPER_EXTENSION_H
  32. #include "../openxr_api_extension.h"
  33. #include "openxr_extension_wrapper.h"
  34. #include "core/object/ref_counted.h"
  35. #include "core/os/os.h"
  36. #include "core/os/thread_safe.h"
  37. #include "core/variant/native_ptr.h"
  38. #include "core/variant/typed_array.h"
  39. class OpenXRExtensionWrapperExtension : public Object, public OpenXRExtensionWrapper, public OpenXRCompositionLayerProvider {
  40. GDCLASS(OpenXRExtensionWrapperExtension, Object);
  41. protected:
  42. _THREAD_SAFE_CLASS_
  43. static void _bind_methods();
  44. Ref<OpenXRAPIExtension> openxr_api;
  45. public:
  46. virtual HashMap<String, bool *> get_requested_extensions() override;
  47. GDVIRTUAL0R(Dictionary, _get_requested_extensions);
  48. virtual void *set_system_properties_and_get_next_pointer(void *p_next_pointer) override;
  49. virtual void *set_instance_create_info_and_get_next_pointer(void *p_next_pointer) override;
  50. virtual void *set_session_create_and_get_next_pointer(void *p_next_pointer) override;
  51. virtual void *set_swapchain_create_info_and_get_next_pointer(void *p_next_pointer) override;
  52. virtual void *set_hand_joint_locations_and_get_next_pointer(int p_hand_index, void *p_next_pointer) override;
  53. virtual int get_composition_layer_count() override;
  54. virtual XrCompositionLayerBaseHeader *get_composition_layer(int p_index) override;
  55. virtual int get_composition_layer_order(int p_index) override;
  56. //TODO workaround as GDExtensionPtr<void> return type results in build error in godot-cpp
  57. GDVIRTUAL1R(uint64_t, _set_system_properties_and_get_next_pointer, GDExtensionPtr<void>);
  58. GDVIRTUAL1R(uint64_t, _set_instance_create_info_and_get_next_pointer, GDExtensionPtr<void>);
  59. GDVIRTUAL1R(uint64_t, _set_session_create_and_get_next_pointer, GDExtensionPtr<void>);
  60. GDVIRTUAL1R(uint64_t, _set_swapchain_create_info_and_get_next_pointer, GDExtensionPtr<void>);
  61. GDVIRTUAL2R(uint64_t, _set_hand_joint_locations_and_get_next_pointer, int, GDExtensionPtr<void>);
  62. GDVIRTUAL0R(int, _get_composition_layer_count);
  63. GDVIRTUAL1R(uint64_t, _get_composition_layer, int);
  64. GDVIRTUAL1R(int, _get_composition_layer_order, int);
  65. virtual PackedStringArray get_suggested_tracker_names() override;
  66. GDVIRTUAL0R(PackedStringArray, _get_suggested_tracker_names);
  67. virtual void on_register_metadata() override;
  68. virtual void on_before_instance_created() override;
  69. virtual void on_instance_created(const XrInstance p_instance) override;
  70. virtual void on_instance_destroyed() override;
  71. virtual void on_session_created(const XrSession p_session) override;
  72. virtual void on_process() override;
  73. virtual void on_pre_render() override;
  74. virtual void on_main_swapchains_created() override;
  75. virtual void on_session_destroyed() override;
  76. virtual void on_pre_draw_viewport(RID p_render_target) override;
  77. virtual void on_post_draw_viewport(RID p_render_target) override;
  78. GDVIRTUAL0(_on_register_metadata);
  79. GDVIRTUAL0(_on_before_instance_created);
  80. GDVIRTUAL1(_on_instance_created, uint64_t);
  81. GDVIRTUAL0(_on_instance_destroyed);
  82. GDVIRTUAL1(_on_session_created, uint64_t);
  83. GDVIRTUAL0(_on_process);
  84. GDVIRTUAL0(_on_pre_render);
  85. GDVIRTUAL0(_on_main_swapchains_created);
  86. GDVIRTUAL0(_on_session_destroyed);
  87. GDVIRTUAL1(_on_pre_draw_viewport, RID);
  88. GDVIRTUAL1(_on_post_draw_viewport, RID);
  89. virtual void on_state_idle() override;
  90. virtual void on_state_ready() override;
  91. virtual void on_state_synchronized() override;
  92. virtual void on_state_visible() override;
  93. virtual void on_state_focused() override;
  94. virtual void on_state_stopping() override;
  95. virtual void on_state_loss_pending() override;
  96. virtual void on_state_exiting() override;
  97. GDVIRTUAL0(_on_state_idle);
  98. GDVIRTUAL0(_on_state_ready);
  99. GDVIRTUAL0(_on_state_synchronized);
  100. GDVIRTUAL0(_on_state_visible);
  101. GDVIRTUAL0(_on_state_focused);
  102. GDVIRTUAL0(_on_state_stopping);
  103. GDVIRTUAL0(_on_state_loss_pending);
  104. GDVIRTUAL0(_on_state_exiting);
  105. virtual bool on_event_polled(const XrEventDataBuffer &p_event) override;
  106. GDVIRTUAL1R(bool, _on_event_polled, GDExtensionConstPtr<void>);
  107. virtual void *set_viewport_composition_layer_and_get_next_pointer(const XrCompositionLayerBaseHeader *p_layer, const Dictionary &p_property_values, void *p_next_pointer) override;
  108. virtual void on_viewport_composition_layer_destroyed(const XrCompositionLayerBaseHeader *p_layer) override;
  109. virtual void get_viewport_composition_layer_extension_properties(List<PropertyInfo> *p_property_list) override;
  110. virtual Dictionary get_viewport_composition_layer_extension_property_defaults() override;
  111. virtual void *set_android_surface_swapchain_create_info_and_get_next_pointer(const Dictionary &p_property_values, void *p_next_pointer) override;
  112. GDVIRTUAL3R(uint64_t, _set_viewport_composition_layer_and_get_next_pointer, GDExtensionConstPtr<void>, Dictionary, GDExtensionPtr<void>);
  113. GDVIRTUAL1(_on_viewport_composition_layer_destroyed, GDExtensionConstPtr<void>);
  114. GDVIRTUAL0R(TypedArray<Dictionary>, _get_viewport_composition_layer_extension_properties);
  115. GDVIRTUAL0R(Dictionary, _get_viewport_composition_layer_extension_property_defaults);
  116. GDVIRTUAL2R(uint64_t, _set_android_surface_swapchain_create_info_and_get_next_pointer, Dictionary, GDExtensionPtr<void>);
  117. Ref<OpenXRAPIExtension> get_openxr_api();
  118. void register_extension_wrapper();
  119. OpenXRExtensionWrapperExtension();
  120. virtual ~OpenXRExtensionWrapperExtension() override;
  121. };
  122. #endif // OPENXR_EXTENSION_WRAPPER_EXTENSION_H