Attention: Here be dragons

This is the latest (unstable) version of this documentation, which may document features not available in or compatible with released stable versions of Godot.

OpenXRAPIExtension

繼承: RefCounted < Object

使 OpenXR API 可用於 GDExtension。

說明

OpenXRAPIExtension 使 OpenXR 可用於 GDExtension。它透過 get_instance_proc_addr() 方法向 GDExtension 提供 OpenXR API,並透過 [methodsion API,並透過 [methodsion get_instance get_instance

它還提供了用於查詢 OpenXR 初始化狀態的方法,以及便於透過 GDExtension 使用 API 的輔助方法。

教學

方法

int

action_get_handle(action: RID)

void

begin_debug_label_region(label_name: String)

bool

can_render()

void

end_debug_label_region()

RID

find_action(name: String, action_set: RID)

String

get_error_string(result: int)

int

get_hand_tracker(hand_index: int)

int

get_instance()

int

get_instance_proc_addr(name: String)

int

get_next_frame_time()

int

get_openxr_version()

int

get_play_space()

int

get_predicted_display_time()

int

get_projection_layer()

float

get_render_state_z_far()

float

get_render_state_z_near()

int

get_session()

PackedInt64Array

get_supported_swapchain_formats()

String

get_swapchain_format_name(swapchain_format: int)

int

get_system_id()

int

get_view_configuration() const

int

get_view_count() const

void

insert_debug_label(label_name: String)

OpenXRAlphaBlendModeSupport

is_environment_blend_mode_alpha_supported()

bool

is_initialized()

bool

is_running()

bool

openxr_is_enabled(check_run_in_editor: bool) static

void

openxr_swapchain_acquire(swapchain: int)

int

openxr_swapchain_create(create_flags: int, usage_flags: int, swapchain_format: int, width: int, height: int, sample_count: int, array_size: int)

void

openxr_swapchain_free(swapchain: int)

RID

openxr_swapchain_get_image(swapchain: int)

int

openxr_swapchain_get_swapchain(swapchain: int)

void

openxr_swapchain_release(swapchain: int)

void

register_composition_layer_provider(extension: OpenXRExtensionWrapper)

void

register_frame_info_extension(extension: OpenXRExtensionWrapper)

void

register_projection_layer_extension(extension: OpenXRExtensionWrapper)

void

register_projection_views_extension(extension: OpenXRExtensionWrapper)

void

set_custom_play_space(space: const void*)

void

set_emulate_environment_blend_mode_alpha_blend(enabled: bool)

void

set_object_name(object_type: int, object_handle: int, object_name: String)

void

set_render_region(render_region: Rect2i)

void

set_velocity_depth_texture(render_target: RID)

void

set_velocity_target_size(target_size: Vector2i)

void

set_velocity_texture(render_target: RID)

Transform3D

transform_from_pose(pose: const void*)

void

unregister_composition_layer_provider(extension: OpenXRExtensionWrapper)

void

unregister_frame_info_extension(extension: OpenXRExtensionWrapper)

void

unregister_projection_layer_extension(extension: OpenXRExtensionWrapper)

void

unregister_projection_views_extension(extension: OpenXRExtensionWrapper)

void

update_main_swapchain_size()

bool

xr_result(result: int, format: String, args: Array)


列舉

enum OpenXRAlphaBlendModeSupport: 🔗

OpenXRAlphaBlendModeSupport OPENXR_ALPHA_BLEND_MODE_SUPPORT_NONE = 0

Means that XRInterface.XR_ENV_BLEND_MODE_ALPHA_BLEND isn't supported at all.

OpenXRAlphaBlendModeSupport OPENXR_ALPHA_BLEND_MODE_SUPPORT_REAL = 1

Means that XRInterface.XR_ENV_BLEND_MODE_ALPHA_BLEND is really supported.

OpenXRAlphaBlendModeSupport OPENXR_ALPHA_BLEND_MODE_SUPPORT_EMULATING = 2

Means that XRInterface.XR_ENV_BLEND_MODE_ALPHA_BLEND is emulated.


方法說明

int action_get_handle(action: RID) 🔗

Returns the corresponding XrAction OpenXR handle for the given action RID.


void begin_debug_label_region(label_name: String) 🔗

Begins a new debug label region, this label will be reported in debug messages for any calls following this until end_debug_label_region() is called. Debug labels can be stacked.


bool can_render() 🔗

如果通訊端是打開的,並且在監聽埠,則返回 true


void end_debug_label_region() 🔗

Marks the end of a debug label region. Removes the latest debug label region added by calling begin_debug_label_region().


RID find_action(name: String, action_set: RID) 🔗

Returns the RID corresponding to an Action of a matching name, optionally limited to a specified action set.


String get_error_string(result: int) 🔗

回傳給定XrResult.


int get_hand_tracker(hand_index: int) 🔗

Returns the corresponding XRHandTrackerEXT handle for the given hand index value.


int get_instance() 🔗

Returns the XrInstance created during the initialization of the OpenXR API.


int get_instance_proc_addr(name: String) 🔗

傳回指定名稱的OpenXR函式的函式指針,轉換為整數。如果指定名稱的函式不存在,則該方法傳回0

注意: openxr/util.h 包含用於取得OpenXR 函式的實用宏,例如GDEXTENSION_INIT_XR_FUNC_V(xrCreateAction)


int get_next_frame_time() 🔗

Returns the predicted display timing for the next frame.


int get_openxr_version() 🔗

Returns the version of OpenXR that was initialized. Only valid after the OpenXR instance has been created. See XR_MAKE_VERSION for how the version is calculated.


int get_play_space() 🔗

回傳播放空間,這是一個 XrSpace 轉換為整數。


int get_predicted_display_time() 🔗

Returns the predicted display timing for the current frame.


int get_projection_layer() 🔗

Returns a pointer to the render state's XrCompositionLayerProjection struct.

Note: This method should only be called from the rendering thread.


float get_render_state_z_far() 🔗

Returns the far boundary value of the camera frustum.

Note: This is only accessible in the render thread.


float get_render_state_z_near() 🔗

Returns the near boundary value of the camera frustum.

Note: This is only accessible in the render thread.


int get_session() 🔗

回傳 OpenXR 會話,它是一個 XrSession 轉換為整數。


PackedInt64Array get_supported_swapchain_formats() 🔗

Returns an array of supported swapchain formats.


String get_swapchain_format_name(swapchain_format: int) 🔗

返回指定參數的值。


int get_system_id() 🔗

Returns the ID of the system, which is an XrSystemId cast to an integer.


int get_view_configuration() const 🔗

Returns the view configuration type, which is an XrViewConfigurationType cast to an integer.


int get_view_count() const 🔗

Returns the number of views. It is usually two, one for each eye, but may differ with different view configurations.


void insert_debug_label(label_name: String) 🔗

Inserts a debug label, this label is reported in any debug message resulting from the OpenXR calls that follows, until any of begin_debug_label_region(), end_debug_label_region(), or insert_debug_label() is called.


OpenXRAlphaBlendModeSupport is_environment_blend_mode_alpha_supported() 🔗

Returns OpenXRAlphaBlendModeSupport denoting if XRInterface.XR_ENV_BLEND_MODE_ALPHA_BLEND is really supported, emulated or not supported at all.


bool is_initialized() 🔗

如果 OpenXR 已初始化,則返回 true


bool is_running() 🔗

如果OpenXR 正在運作,則傳回true (xrBeginSession 已成功呼叫並建立了交換鏈)。


bool openxr_is_enabled(check_run_in_editor: bool) static 🔗

如果啟用 OpenXR,則返回 true


void openxr_swapchain_acquire(swapchain: int) 🔗

Acquires the image of the provided swapchain.


int openxr_swapchain_create(create_flags: int, usage_flags: int, swapchain_format: int, width: int, height: int, sample_count: int, array_size: int) 🔗

Returns a pointer to a new swapchain created using the provided parameters.


void openxr_swapchain_free(swapchain: int) 🔗

Destroys the provided swapchain and frees it from memory.


RID openxr_swapchain_get_image(swapchain: int) 🔗

Returns the RID of the provided swapchain's image.


int openxr_swapchain_get_swapchain(swapchain: int) 🔗

Returns the XrSwapchain handle of the provided swapchain.


void openxr_swapchain_release(swapchain: int) 🔗

Releases the image of the provided swapchain.


void register_composition_layer_provider(extension: OpenXRExtensionWrapper) 🔗

Registers the given extension as a composition layer provider.

Note: This cannot be called after the OpenXR session has started. However, it can be called in OpenXRExtensionWrapper._on_session_created().


void register_frame_info_extension(extension: OpenXRExtensionWrapper) 🔗

Registers the given extension as modifying frame info via the OpenXRExtensionWrapper._set_frame_wait_info_and_get_next_pointer(), OpenXRExtensionWrapper._set_view_locate_info_and_get_next_pointer(), or OpenXRExtensionWrapper._set_frame_end_info_and_get_next_pointer() virtual methods.

Note: This cannot be called after the OpenXR session has started. However, it can be called in OpenXRExtensionWrapper._on_session_created().


void register_projection_layer_extension(extension: OpenXRExtensionWrapper) 🔗

Registers the given extension as modifying XrCompositionLayerProjection via the OpenXRExtensionWrapper._set_projection_layer_and_get_next_pointer() virtual method.

Note: This cannot be called after the OpenXR session has started. However, it can be called in OpenXRExtensionWrapper._on_session_created().


void register_projection_views_extension(extension: OpenXRExtensionWrapper) 🔗

Registers the given extension as a provider of additional data structures to projections views.

Note: This cannot be called after the OpenXR session has started. However, it can be called in OpenXRExtensionWrapper._on_session_created().


void set_custom_play_space(space: const void*) 🔗

Sets the reference space used by OpenXR to the given XrSpace (cast to a void *).


void set_emulate_environment_blend_mode_alpha_blend(enabled: bool) 🔗

If set to true, an OpenXR extension is loaded which is capable of emulating the XRInterface.XR_ENV_BLEND_MODE_ALPHA_BLEND blend mode.


void set_object_name(object_type: int, object_handle: int, object_name: String) 🔗

Set the object name of an OpenXR object, used for debug output. object_type must be a valid OpenXR XrObjectType enum and object_handle must be a valid OpenXR object handle.


void set_render_region(render_region: Rect2i) 🔗

Sets the render region to render_region, overriding the normal render target's rect.


void set_velocity_depth_texture(render_target: RID) 🔗

Sets the render target of the velocity depth texture.


void set_velocity_target_size(target_size: Vector2i) 🔗

Sets the target size of the velocity and velocity depth textures.


void set_velocity_texture(render_target: RID) 🔗

Sets the render target of the velocity texture.


Transform3D transform_from_pose(pose: const void*) 🔗

XrPosef.


void unregister_composition_layer_provider(extension: OpenXRExtensionWrapper) 🔗

Unregisters the given extension as a composition layer provider.

Note: This cannot be called while the OpenXR session is still running.


void unregister_frame_info_extension(extension: OpenXRExtensionWrapper) 🔗

Unregisters the given extension as modifying frame info.

Note: This cannot be called while the OpenXR session is still running.


void unregister_projection_layer_extension(extension: OpenXRExtensionWrapper) 🔗

Unregisters the given extension as modifying XrCompositionLayerProjection.

Note: This cannot be called while the OpenXR session is still running.


void unregister_projection_views_extension(extension: OpenXRExtensionWrapper) 🔗

Unregisters the given extension as a provider of additional data structures to projections views.

Note: This cannot be called while the OpenXR session is still running.


void update_main_swapchain_size() 🔗

Request the recommended resolution from the OpenXR runtime and update the main swapchain size if it has changed.


bool xr_result(result: int, format: String, args: Array) 🔗

如果提供的 XrResult(轉換為整數)成功則回傳true。否則返回 false 並列印 XrResult 轉換為字串,帶有指定的附加資訊。