Path: blob/master/modules/openxr/openxr_api_extension.h
21677 views
/**************************************************************************/1/* openxr_api_extension.h */2/**************************************************************************/3/* This file is part of: */4/* GODOT ENGINE */5/* https://godotengine.org */6/**************************************************************************/7/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */8/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */9/* */10/* Permission is hereby granted, free of charge, to any person obtaining */11/* a copy of this software and associated documentation files (the */12/* "Software"), to deal in the Software without restriction, including */13/* without limitation the rights to use, copy, modify, merge, publish, */14/* distribute, sublicense, and/or sell copies of the Software, and to */15/* permit persons to whom the Software is furnished to do so, subject to */16/* the following conditions: */17/* */18/* The above copyright notice and this permission notice shall be */19/* included in all copies or substantial portions of the Software. */20/* */21/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */22/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */23/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */24/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */25/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */26/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */27/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */28/**************************************************************************/2930#pragma once3132#include "openxr_api.h"3334#include "core/object/ref_counted.h"35#include "core/os/thread_safe.h"36#include "core/variant/native_ptr.h"3738class OpenXRExtensionWrapper;39class OpenXRExtensionWrapperExtension;4041class OpenXRAPIExtension : public RefCounted {42GDCLASS(OpenXRAPIExtension, RefCounted);4344protected:45_THREAD_SAFE_CLASS_4647static void _bind_methods();4849#ifndef DISABLE_DEPRECATED50static void _bind_compatibility_methods();51void _register_composition_layer_provider_bind_compat_104087(OpenXRExtensionWrapperExtension *p_extension);52void _unregister_composition_layer_provider_bind_compat_104087(OpenXRExtensionWrapperExtension *p_extension);53void _register_projection_views_extension_bind_compat_104087(OpenXRExtensionWrapperExtension *p_extension);54void _unregister_projection_views_extension_bind_compat_104087(OpenXRExtensionWrapperExtension *p_extension);55#endif5657public:58uint64_t get_openxr_version();59uint64_t get_instance();60uint64_t get_system_id();61uint64_t get_session();6263// Helper method to convert an XrPosef to a Transform3D.64Transform3D transform_from_pose(GDExtensionConstPtr<const void> p_pose);6566bool xr_result(uint64_t p_result, const String &p_format, const Array &p_args = Array());6768static bool openxr_is_enabled(bool p_check_run_in_editor = true);6970//TODO workaround as GDExtensionPtr<void> return type results in build error in godot-cpp71uint64_t get_instance_proc_addr(const String &p_name);72String get_error_string(uint64_t result);73String get_swapchain_format_name(int64_t p_swapchain_format);74void set_object_name(int64_t p_object_type, uint64_t p_object_handle, const String &p_object_name);75void begin_debug_label_region(const String &p_label_name);76void end_debug_label_region();77void insert_debug_label(const String &p_label_name);7879bool is_initialized();80bool is_running();8182void set_custom_play_space(GDExtensionConstPtr<const void> p_custom_space);83uint64_t get_play_space();84int64_t get_predicted_display_time();85int64_t get_next_frame_time();86bool can_render();8788RID find_action(const String &p_name, const RID &p_action_set = RID());89uint64_t action_get_handle(RID p_action);9091uint64_t get_hand_tracker(int p_hand_index);9293void register_composition_layer_provider(OpenXRExtensionWrapper *p_extension);94void unregister_composition_layer_provider(OpenXRExtensionWrapper *p_extension);9596void register_projection_views_extension(OpenXRExtensionWrapper *p_extension);97void unregister_projection_views_extension(OpenXRExtensionWrapper *p_extension);9899void register_frame_info_extension(OpenXRExtensionWrapper *p_extension);100void unregister_frame_info_extension(OpenXRExtensionWrapper *p_extension);101102double get_render_state_z_near();103double get_render_state_z_far();104105void set_velocity_texture(RID p_render_target);106void set_velocity_depth_texture(RID p_render_target);107void set_velocity_target_size(const Size2i &p_target_size);108109PackedInt64Array get_supported_swapchain_formats();110111uint64_t openxr_swapchain_create(XrSwapchainCreateFlags p_create_flags, XrSwapchainUsageFlags p_usage_flags, int64_t p_swapchain_format, uint32_t p_width, uint32_t p_height, uint32_t p_sample_count, uint32_t p_array_size);112void openxr_swapchain_free(uint64_t p_swapchain_info);113uint64_t openxr_swapchain_get_swapchain(uint64_t p_swapchain_info);114void openxr_swapchain_acquire(uint64_t p_swapchain_info);115RID openxr_swapchain_get_image(uint64_t p_swapchain_info);116void openxr_swapchain_release(uint64_t p_swapchain_info);117118uint64_t get_projection_layer();119120void set_render_region(const Rect2i &p_render_region);121122void update_main_swapchain_size();123124enum OpenXRAlphaBlendModeSupport {125OPENXR_ALPHA_BLEND_MODE_SUPPORT_NONE = 0,126OPENXR_ALPHA_BLEND_MODE_SUPPORT_REAL = 1,127OPENXR_ALPHA_BLEND_MODE_SUPPORT_EMULATING = 2,128};129130void set_emulate_environment_blend_mode_alpha_blend(bool p_enabled);131OpenXRAlphaBlendModeSupport is_environment_blend_mode_alpha_blend_supported();132133OpenXRAPIExtension();134};135136VARIANT_ENUM_CAST(OpenXRAPIExtension::OpenXRAlphaBlendModeSupport);137138139