Path: blob/master/modules/openxr/openxr_api_extension.h
10277 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_instance();59uint64_t get_system_id();60uint64_t get_session();6162// Helper method to convert an XrPosef to a Transform3D.63Transform3D transform_from_pose(GDExtensionConstPtr<const void> p_pose);6465bool xr_result(uint64_t result, String format, Array args = Array());6667static bool openxr_is_enabled(bool p_check_run_in_editor = true);6869//TODO workaround as GDExtensionPtr<void> return type results in build error in godot-cpp70uint64_t get_instance_proc_addr(String p_name);71String get_error_string(uint64_t result);72String get_swapchain_format_name(int64_t p_swapchain_format);73void set_object_name(int64_t p_object_type, uint64_t p_object_handle, const String &p_object_name);74void begin_debug_label_region(const String &p_label_name);75void end_debug_label_region();76void insert_debug_label(const String &p_label_name);7778bool is_initialized();79bool is_running();8081void set_custom_play_space(GDExtensionConstPtr<const void> p_custom_space);82uint64_t get_play_space();83int64_t get_predicted_display_time();84int64_t get_next_frame_time();85bool can_render();8687RID find_action(const String &p_name, const RID &p_action_set = RID());88uint64_t action_get_handle(RID p_action);8990uint64_t get_hand_tracker(int p_hand_index);9192void register_composition_layer_provider(OpenXRExtensionWrapper *p_extension);93void unregister_composition_layer_provider(OpenXRExtensionWrapper *p_extension);9495void register_projection_views_extension(OpenXRExtensionWrapper *p_extension);96void unregister_projection_views_extension(OpenXRExtensionWrapper *p_extension);9798void register_frame_info_extension(OpenXRExtensionWrapper *p_extension);99void unregister_frame_info_extension(OpenXRExtensionWrapper *p_extension);100101double get_render_state_z_near();102double get_render_state_z_far();103104void set_velocity_texture(RID p_render_target);105void set_velocity_depth_texture(RID p_render_target);106void set_velocity_target_size(const Size2i &p_target_size);107108PackedInt64Array get_supported_swapchain_formats();109110uint64_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);111void openxr_swapchain_free(uint64_t p_swapchain_info);112uint64_t openxr_swapchain_get_swapchain(uint64_t p_swapchain_info);113void openxr_swapchain_acquire(uint64_t p_swapchain_info);114RID openxr_swapchain_get_image(uint64_t p_swapchain_info);115void openxr_swapchain_release(uint64_t p_swapchain_info);116117uint64_t get_projection_layer();118119void set_render_region(const Rect2i &p_render_region);120121enum OpenXRAlphaBlendModeSupport {122OPENXR_ALPHA_BLEND_MODE_SUPPORT_NONE = 0,123OPENXR_ALPHA_BLEND_MODE_SUPPORT_REAL = 1,124OPENXR_ALPHA_BLEND_MODE_SUPPORT_EMULATING = 2,125};126127void set_emulate_environment_blend_mode_alpha_blend(bool p_enabled);128OpenXRAlphaBlendModeSupport is_environment_blend_mode_alpha_blend_supported();129130OpenXRAPIExtension();131};132133VARIANT_ENUM_CAST(OpenXRAPIExtension::OpenXRAlphaBlendModeSupport);134135136