Class reference
OpenXRAPIExtension
Inherits RefCounted
Makes the OpenXR API available for GDExtension.
Description
OpenXRAPIExtension makes OpenXR available for GDExtension. It provides the OpenXR API to GDExtension through the get_instance_proc_addr() method, and the OpenXR instance through get_instance(). It also provides methods for querying the status of OpenXR initialization, and helper methods for ease of use of the API with GDExtension.
Methods
int action_get_handle(RID action)
int action_get_handle(RID action)Returns the corresponding XrAction OpenXR handle for the given action RID.
void begin_debug_label_region(String label_name)
String label_name)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()
bool can_render()Returns true if OpenXR is initialized for rendering with an XR viewport.
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(String name, RID action_set)
RID find_action(String name, RID action_set)Returns the RID corresponding to an Action of a matching name, optionally limited to a specified action set.
String get_error_string(int result)
String get_error_string(int result)Returns an error string for the given XrResult.
int get_hand_tracker(int hand_index)
int get_hand_tracker(int hand_index)Returns the corresponding XRHandTrackerEXT handle for the given hand index value.
int get_instance()
int get_instance()Returns the XrInstance created during the initialization of the OpenXR API.
int get_instance_proc_addr(String name)
int get_instance_proc_addr(String name)Returns the function pointer of the OpenXR function with the specified name, cast to an integer. If the function with the given name does not exist, the method returns 0. Note: openxr/util.h contains utility macros for acquiring OpenXR functions, e.g. GDEXTENSION_INIT_XR_FUNC_V(xrCreateAction).
int get_next_frame_time()
int get_next_frame_time()Returns the predicted display timing for the next frame.
int get_play_space()
int get_play_space()Returns the play space, which is an XrSpace cast to an integer.
int get_predicted_display_time()
int get_predicted_display_time()Returns the predicted display timing for the current frame.
int get_projection_layer()
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()
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()
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()
int get_session()Returns the OpenXR session, which is an XrSession cast to an integer.
PackedInt64Array get_supported_swapchain_formats()
PackedInt64Array get_supported_swapchain_formats()Returns an array of supported swapchain formats.
String get_swapchain_format_name(int swapchain_format)
String get_swapchain_format_name(int swapchain_format)Returns the name of the specified swapchain format.
int get_system_id()
int get_system_id()Returns the id of the system, which is an XrSystemId cast to an integer.
void insert_debug_label(String label_name)
String label_name)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.
int is_environment_blend_mode_alpha_supported()
int is_environment_blend_mode_alpha_supported()Returns OpenXRAPIExtension.OpenXRAlphaBlendModeSupport denoting if XRInterface.XR_ENV_BLEND_MODE_ALPHA_BLEND is really supported, emulated or not supported at all.
bool is_initialized()
bool is_initialized()Returns true if OpenXR is initialized.
bool is_running()
bool is_running()Returns true if OpenXR is running (xrBeginSession was successfully called and the swapchains were created).
bool openxr_is_enabled(bool check_run_in_editor) static
bool openxr_is_enabled(bool check_run_in_editor) staticReturns true if OpenXR is enabled.
void openxr_swapchain_acquire(int swapchain)
int swapchain)Acquires the image of the provided swapchain.
int openxr_swapchain_create(int create_flags, int usage_flags, int swapchain_format, int width, int height, int sample_count, int array_size)
int openxr_swapchain_create(int create_flags, int usage_flags, int swapchain_format, int width, int height, int sample_count, int array_size)Returns a pointer to a new swapchain created using the provided parameters.
void openxr_swapchain_free(int swapchain)
int swapchain)Destroys the provided swapchain and frees it from memory.
RID openxr_swapchain_get_image(int swapchain)
RID openxr_swapchain_get_image(int swapchain)Returns the RID of the provided swapchain's image.
int openxr_swapchain_get_swapchain(int swapchain)
int openxr_swapchain_get_swapchain(int swapchain)Returns the XrSwapchain handle of the provided swapchain.
void openxr_swapchain_release(int swapchain)
int swapchain)Releases the image of the provided swapchain.
void register_composition_layer_provider(OpenXRExtensionWrapper extension)
OpenXRExtensionWrapper extension)Registers the given extension as a composition layer provider.
void register_frame_info_extension(OpenXRExtensionWrapper extension)
OpenXRExtensionWrapper extension)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.
void register_projection_views_extension(OpenXRExtensionWrapper extension)
OpenXRExtensionWrapper extension)Registers the given extension as a provider of additional data structures to projections views.
void set_custom_play_space(const void* space)
Sets the reference space used by OpenXR to the given XrSpace (cast to a void *).
void set_emulate_environment_blend_mode_alpha_blend(bool enabled)
bool enabled)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(int object_type, int object_handle, String object_name)
int object_type, int object_handle, String object_name)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(Rect2i render_region)
Rect2i render_region)Sets the render region to render_region, overriding the normal render target's rect.
void set_velocity_depth_texture(RID render_target)
RID render_target)Sets the render target of the velocity depth texture.
void set_velocity_target_size(Vector2i target_size)
Vector2i target_size)Sets the target size of the velocity and velocity depth textures.
void set_velocity_texture(RID render_target)
RID render_target)Sets the render target of the velocity texture.
Transform3D transform_from_pose(const void* pose)
Transform3D transform_from_pose(const void* pose)Creates a Transform3D from an XrPosef.
void unregister_composition_layer_provider(OpenXRExtensionWrapper extension)
OpenXRExtensionWrapper extension)Unregisters the given extension as a composition layer provider.
void unregister_frame_info_extension(OpenXRExtensionWrapper extension)
OpenXRExtensionWrapper extension)Unregisters the given extension as modifying frame info.
void unregister_projection_views_extension(OpenXRExtensionWrapper extension)
OpenXRExtensionWrapper extension)Unregisters the given extension as a provider of additional data structures to projections views.
bool xr_result(int result, String format, Array args)
bool xr_result(int result, String format, Array args)Returns true if the provided XrResult (cast to an integer) is successful. Otherwise returns false and prints the XrResult converted to a string, with the specified additional information.
Constants
OPENXR_ALPHA_BLEND_MODE_SUPPORT_NONE = 0
Means that XRInterface.XR_ENV_BLEND_MODE_ALPHA_BLEND isn't supported at all.
OPENXR_ALPHA_BLEND_MODE_SUPPORT_REAL = 1
Means that XRInterface.XR_ENV_BLEND_MODE_ALPHA_BLEND is really supported.
OPENXR_ALPHA_BLEND_MODE_SUPPORT_EMULATING = 2
Means that XRInterface.XR_ENV_BLEND_MODE_ALPHA_BLEND is emulated.