openxr_extension_wrapper_extension.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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. class OpenXRExtensionWrapperExtension : public Object, OpenXRExtensionWrapper {
  39. GDCLASS(OpenXRExtensionWrapperExtension, Object);
  40. protected:
  41. _THREAD_SAFE_CLASS_
  42. static void _bind_methods();
  43. Ref<OpenXRAPIExtension> openxr_api;
  44. public:
  45. virtual HashMap<String, bool *> get_requested_extensions() override;
  46. GDVIRTUAL0R(Dictionary, _get_requested_extensions);
  47. virtual void *set_system_properties_and_get_next_pointer(void *p_next_pointer) override;
  48. virtual void *set_instance_create_info_and_get_next_pointer(void *p_next_pointer) override;
  49. virtual void *set_session_create_and_get_next_pointer(void *p_next_pointer) override;
  50. virtual void *set_swapchain_create_info_and_get_next_pointer(void *p_next_pointer) override;
  51. //TODO workaround as GDExtensionPtr<void> return type results in build error in godot-cpp
  52. GDVIRTUAL1R(uint64_t, _set_system_properties_and_get_next_pointer, GDExtensionPtr<void>);
  53. GDVIRTUAL1R(uint64_t, _set_instance_create_info_and_get_next_pointer, GDExtensionPtr<void>);
  54. GDVIRTUAL1R(uint64_t, _set_session_create_and_get_next_pointer, GDExtensionPtr<void>);
  55. GDVIRTUAL1R(uint64_t, _set_swapchain_create_info_and_get_next_pointer, GDExtensionPtr<void>);
  56. virtual void on_register_metadata() override;
  57. virtual void on_before_instance_created() override;
  58. virtual void on_instance_created(const XrInstance p_instance) override;
  59. virtual void on_instance_destroyed() override;
  60. virtual void on_session_created(const XrSession p_session) override;
  61. virtual void on_process() override;
  62. virtual void on_pre_render() override;
  63. virtual void on_session_destroyed() override;
  64. GDVIRTUAL0(_on_register_metadata);
  65. GDVIRTUAL0(_on_before_instance_created);
  66. GDVIRTUAL1(_on_instance_created, uint64_t);
  67. GDVIRTUAL0(_on_instance_destroyed);
  68. GDVIRTUAL1(_on_session_created, uint64_t);
  69. GDVIRTUAL0(_on_process);
  70. GDVIRTUAL0(_on_pre_render);
  71. GDVIRTUAL0(_on_session_destroyed);
  72. virtual void on_state_idle() override;
  73. virtual void on_state_ready() override;
  74. virtual void on_state_synchronized() override;
  75. virtual void on_state_visible() override;
  76. virtual void on_state_focused() override;
  77. virtual void on_state_stopping() override;
  78. virtual void on_state_loss_pending() override;
  79. virtual void on_state_exiting() override;
  80. GDVIRTUAL0(_on_state_idle);
  81. GDVIRTUAL0(_on_state_ready);
  82. GDVIRTUAL0(_on_state_synchronized);
  83. GDVIRTUAL0(_on_state_visible);
  84. GDVIRTUAL0(_on_state_focused);
  85. GDVIRTUAL0(_on_state_stopping);
  86. GDVIRTUAL0(_on_state_loss_pending);
  87. GDVIRTUAL0(_on_state_exiting);
  88. virtual bool on_event_polled(const XrEventDataBuffer &p_event) override;
  89. GDVIRTUAL1R(bool, _on_event_polled, GDExtensionConstPtr<void>);
  90. Ref<OpenXRAPIExtension> get_openxr_api();
  91. void register_extension_wrapper();
  92. OpenXRExtensionWrapperExtension();
  93. };
  94. #endif // OPENXR_EXTENSION_WRAPPER_EXTENSION_H