Table of Contents

Class OpenXRApiExtension

Namespace
Godot
Assembly
GodotSharp.dll

OpenXRApiExtension makes OpenXR available for GDExtension. It provides the OpenXR API to GDExtension through the GetInstanceProcAddr(string) method, and the OpenXR instance through GetInstance().

It also provides methods for querying the status of OpenXR initialization, and helper methods for ease of use of the API with GDExtension.

[GodotClassName("OpenXRAPIExtension")]
public class OpenXRApiExtension : RefCounted, IDisposable
Inheritance
OpenXRApiExtension
Implements
Inherited Members

Constructors

OpenXRApiExtension()

public OpenXRApiExtension()

Methods

ActionGetHandle(Rid)

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

public ulong ActionGetHandle(Rid action)

Parameters

action Rid

Returns

ulong

BeginDebugLabelRegion(string)

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

public void BeginDebugLabelRegion(string labelName)

Parameters

labelName string

CanRender()

Returns true if OpenXR is initialized for rendering with an XR viewport.

public bool CanRender()

Returns

bool

EndDebugLabelRegion()

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

public void EndDebugLabelRegion()

FindAction(string, Rid)

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

public Rid FindAction(string name, Rid actionSet)

Parameters

name string
actionSet Rid

Returns

Rid

GetErrorString(ulong)

Returns an error string for the given XrResult.

public string GetErrorString(ulong result)

Parameters

result ulong

Returns

string

GetHandTracker(int)

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

public ulong GetHandTracker(int handIndex)

Parameters

handIndex int

Returns

ulong

GetInstance()

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

public ulong GetInstance()

Returns

ulong

GetInstanceProcAddr(string)

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).

public ulong GetInstanceProcAddr(string name)

Parameters

name string

Returns

ulong

GetNextFrameTime()

Returns the predicted display timing for the next frame.

public long GetNextFrameTime()

Returns

long

GetPlaySpace()

Returns the play space, which is an XrSpace cast to an integer.

public ulong GetPlaySpace()

Returns

ulong

GetPredictedDisplayTime()

Returns the predicted display timing for the current frame.

public long GetPredictedDisplayTime()

Returns

long

GetProjectionLayer()

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

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

public ulong GetProjectionLayer()

Returns

ulong

GetRenderStateZFar()

Returns the far boundary value of the camera frustum.

Note: This is only accessible in the render thread.

public double GetRenderStateZFar()

Returns

double

GetRenderStateZNear()

Returns the near boundary value of the camera frustum.

Note: This is only accessible in the render thread.

public double GetRenderStateZNear()

Returns

double

GetSession()

Returns the OpenXR session, which is an XrSession cast to an integer.

public ulong GetSession()

Returns

ulong

GetSupportedSwapchainFormats()

Returns an array of supported swapchain formats.

public long[] GetSupportedSwapchainFormats()

Returns

long[]

GetSwapchainFormatName(long)

Returns the name of the specified swapchain format.

public string GetSwapchainFormatName(long swapchainFormat)

Parameters

swapchainFormat long

Returns

string

GetSystemId()

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

public ulong GetSystemId()

Returns

ulong

HasGodotClassMethod(in godot_string_name)

Check if the type contains a method with the given name. This method is used by Godot to check if a method exists before invoking it. Do not call or override this method.

protected override bool HasGodotClassMethod(in godot_string_name method)

Parameters

method godot_string_name

Name of the method to check for.

Returns

bool

HasGodotClassSignal(in godot_string_name)

Check if the type contains a signal with the given name. This method is used by Godot to check if a signal exists before raising it. Do not call or override this method.

protected override bool HasGodotClassSignal(in godot_string_name signal)

Parameters

signal godot_string_name

Name of the signal to check for.

Returns

bool

InsertDebugLabel(string)

Inserts a debug label, this label is reported in any debug message resulting from the OpenXR calls that follows, until any of BeginDebugLabelRegion(string), EndDebugLabelRegion(), or InsertDebugLabel(string) is called.

public void InsertDebugLabel(string labelName)

Parameters

labelName string

InvokeGodotClassMethod(in godot_string_name, NativeVariantPtrArgs, out godot_variant)

Invokes the method with the given name, using the given arguments. This method is used by Godot to invoke methods from the engine side. Do not call or override this method.

protected override bool InvokeGodotClassMethod(in godot_string_name method, NativeVariantPtrArgs args, out godot_variant ret)

Parameters

method godot_string_name

Name of the method to invoke.

args NativeVariantPtrArgs

Arguments to use with the invoked method.

ret godot_variant

Value returned by the invoked method.

Returns

bool

IsEnvironmentBlendModeAlphaSupported()

Returns OpenXRApiExtension.OpenXRAlphaBlendModeSupport denoting if AlphaBlend is really supported, emulated or not supported at all.

public OpenXRApiExtension.OpenXRAlphaBlendModeSupport IsEnvironmentBlendModeAlphaSupported()

Returns

OpenXRApiExtension.OpenXRAlphaBlendModeSupport

IsInitialized()

Returns true if OpenXR is initialized.

public bool IsInitialized()

Returns

bool

IsRunning()

Returns true if OpenXR is running (xrBeginSession was successfully called and the swapchains were created).

public bool IsRunning()

Returns

bool

OpenxrIsEnabled(bool)

Returns true if OpenXR is enabled.

public static bool OpenxrIsEnabled(bool checkRunInEditor)

Parameters

checkRunInEditor bool

Returns

bool

OpenxrSwapchainAcquire(ulong)

Acquires the image of the provided swapchain.

public void OpenxrSwapchainAcquire(ulong swapchain)

Parameters

swapchain ulong

OpenxrSwapchainCreate(ulong, ulong, long, uint, uint, uint, uint)

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

public ulong OpenxrSwapchainCreate(ulong createFlags, ulong usageFlags, long swapchainFormat, uint width, uint height, uint sampleCount, uint arraySize)

Parameters

createFlags ulong
usageFlags ulong
swapchainFormat long
width uint
height uint
sampleCount uint
arraySize uint

Returns

ulong

OpenxrSwapchainFree(ulong)

Destroys the provided swapchain and frees it from memory.

public void OpenxrSwapchainFree(ulong swapchain)

Parameters

swapchain ulong

OpenxrSwapchainGetImage(ulong)

Returns the RID of the provided swapchain's image.

public Rid OpenxrSwapchainGetImage(ulong swapchain)

Parameters

swapchain ulong

Returns

Rid

OpenxrSwapchainGetSwapchain(ulong)

Returns the XrSwapchain handle of the provided swapchain.

public ulong OpenxrSwapchainGetSwapchain(ulong swapchain)

Parameters

swapchain ulong

Returns

ulong

OpenxrSwapchainRelease(ulong)

Releases the image of the provided swapchain.

public void OpenxrSwapchainRelease(ulong swapchain)

Parameters

swapchain ulong

RegisterCompositionLayerProvider(OpenXRExtensionWrapperExtension)

Registers the given extension as a composition layer provider.

public void RegisterCompositionLayerProvider(OpenXRExtensionWrapperExtension extension)

Parameters

extension OpenXRExtensionWrapperExtension

RegisterProjectionViewsExtension(OpenXRExtensionWrapperExtension)

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

public void RegisterProjectionViewsExtension(OpenXRExtensionWrapperExtension extension)

Parameters

extension OpenXRExtensionWrapperExtension

SetEmulateEnvironmentBlendModeAlphaBlend(bool)

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

public void SetEmulateEnvironmentBlendModeAlphaBlend(bool enabled)

Parameters

enabled bool

SetObjectName(long, ulong, string)

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

public void SetObjectName(long objectType, ulong objectHandle, string objectName)

Parameters

objectType long
objectHandle ulong
objectName string

SetRenderRegion(Rect2I)

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

public void SetRenderRegion(Rect2I renderRegion)

Parameters

renderRegion Rect2I

SetVelocityDepthTexture(Rid)

Sets the render target of the velocity depth texture.

public void SetVelocityDepthTexture(Rid renderTarget)

Parameters

renderTarget Rid

SetVelocityTargetSize(Vector2I)

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

public void SetVelocityTargetSize(Vector2I targetSize)

Parameters

targetSize Vector2I

SetVelocityTexture(Rid)

Sets the render target of the velocity texture.

public void SetVelocityTexture(Rid renderTarget)

Parameters

renderTarget Rid

UnregisterCompositionLayerProvider(OpenXRExtensionWrapperExtension)

Unregisters the given extension as a composition layer provider.

public void UnregisterCompositionLayerProvider(OpenXRExtensionWrapperExtension extension)

Parameters

extension OpenXRExtensionWrapperExtension

UnregisterProjectionViewsExtension(OpenXRExtensionWrapperExtension)

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

public void UnregisterProjectionViewsExtension(OpenXRExtensionWrapperExtension extension)

Parameters

extension OpenXRExtensionWrapperExtension

XRResult(ulong, string, Array)

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.

public bool XRResult(ulong result, string format, Array args)

Parameters

result ulong
format string
args Array

Returns

bool