openxr_api_extension.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. #ifndef OPENXR_API_EXTENSION_H
  31. #define OPENXR_API_EXTENSION_H
  32. #include "openxr_api.h"
  33. #include "core/object/ref_counted.h"
  34. #include "core/os/os.h"
  35. #include "core/os/thread_safe.h"
  36. #include "core/variant/native_ptr.h"
  37. class OpenXRExtensionWrapperExtension;
  38. class OpenXRAPIExtension : public RefCounted {
  39. GDCLASS(OpenXRAPIExtension, RefCounted);
  40. protected:
  41. _THREAD_SAFE_CLASS_
  42. static void _bind_methods();
  43. public:
  44. uint64_t get_instance();
  45. uint64_t get_system_id();
  46. uint64_t get_session();
  47. // Helper method to convert an XrPosef to a Transform3D.
  48. Transform3D transform_from_pose(GDExtensionConstPtr<const void> p_pose);
  49. bool xr_result(uint64_t result, String format, Array args = Array());
  50. static bool openxr_is_enabled(bool p_check_run_in_editor = true);
  51. //TODO workaround as GDExtensionPtr<void> return type results in build error in godot-cpp
  52. uint64_t get_instance_proc_addr(String p_name);
  53. String get_error_string(uint64_t result);
  54. String get_swapchain_format_name(int64_t p_swapchain_format);
  55. void set_object_name(int64_t p_object_type, uint64_t p_object_handle, const String &p_object_name);
  56. void begin_debug_label_region(const String &p_label_name);
  57. void end_debug_label_region();
  58. void insert_debug_label(const String &p_label_name);
  59. bool is_initialized();
  60. bool is_running();
  61. uint64_t get_play_space();
  62. int64_t get_predicted_display_time();
  63. int64_t get_next_frame_time();
  64. bool can_render();
  65. uint64_t get_hand_tracker(int p_hand_index);
  66. void register_composition_layer_provider(OpenXRExtensionWrapperExtension *p_extension);
  67. void unregister_composition_layer_provider(OpenXRExtensionWrapperExtension *p_extension);
  68. enum OpenXRAlphaBlendModeSupport {
  69. OPENXR_ALPHA_BLEND_MODE_SUPPORT_NONE = 0,
  70. OPENXR_ALPHA_BLEND_MODE_SUPPORT_REAL = 1,
  71. OPENXR_ALPHA_BLEND_MODE_SUPPORT_EMULATING = 2,
  72. };
  73. void set_emulate_environment_blend_mode_alpha_blend(bool p_enabled);
  74. OpenXRAlphaBlendModeSupport is_environment_blend_mode_alpha_blend_supported();
  75. OpenXRAPIExtension();
  76. };
  77. VARIANT_ENUM_CAST(OpenXRAPIExtension::OpenXRAlphaBlendModeSupport);
  78. #endif // OPENXR_API_EXTENSION_H