reckfellENGINE

OpenXRExtensionWrapper

Allows implementing OpenXR extensions with ReckfellExtension.

On this page
class OpenXRExtensionWrapperReckfellSharpInherits ReckfellObject

Allows implementing OpenXR extensions with ReckfellExtension.

OpenXRExtensionWrapper allows implementing OpenXR extensions with ReckfellExtension. The extension should be registered with OpenXRExtensionWrapper.RegisterExtensionWrapper. When OpenXRInterface is initialized as the primary interface and any Viewport has Viewport.UseXR set to true, OpenXR will become involved in Reckfell's rendering process. If ProjectSettings.rendering/driver/threads/thread_model is set to "Separate", Reckfell's renderer will run on its own thread, and special care must be taken in all OpenXRExtensionWrappers in order to prevent crashes or unexpected behavior. Some virtual methods will be called on the render thread, and any data they access should not be directly written to on the main thread. This is to prevent two potential issues:

  1. Changes intended for the next frame, taking effect on the current frame. When using the "Separate" thread model, the main thread will immediately start working on the next frame while the render thread may still be rendering the current frame. If the main thread changes anything used by the render thread directly, the change could end up being used one frame earlier than intended.
  2. Reading and writing to the same data at the same time from different threads can lead to the render thread using data in an invalid state. In most cases, the solution is to use RenderingServer.CallOnRenderThread to schedule Callables to write to any data used on the render thread. When using the "Separate" thread model, these Callables will run after the renderer finishes the current frame and before it starts rendering the next frame. When not using this mode, they'll run immediately, so it's recommended to always use RenderingServer.CallOnRenderThread in these cases, which will allow your code to do the right thing regardless of the thread model. Any virtual methods that run on the render thread will be noted below.

Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.

Constructors1

OpenXRExtensionWrapperConstructor
# OpenXRExtensionWrapper
C#
public OpenXRExtensionWrapper();

Methods33

GetOpenxrApiOpenXRApiExtension
# GetOpenxrApi
C#
public OpenXRApiExtension GetOpenxrApi();

Returns the created OpenXRApiExtension, which can be used to access the OpenXR API.

Returns OpenXRApiExtension
RegisterExtensionWrappervoid
# RegisterExtensionWrapper
C#
public void RegisterExtensionWrapper();

Registers the extension. This should happen at core module initialization level. Note: This cannot be called once OpenXR has been initialized.

_GetCameraOffsetsReckfell.Collections.Array<Transform3D>
# _GetCameraOffsets
C#
public virtual Reckfell.Collections.Array<Transform3D> _GetCameraOffsets(StringName trackerName);

Returns an array of offsets for each view rendered for the given camera, if this camera is handled by this extension. tracker_name refers to the camera tracker for which we're retrieving this.

Parameters
NameTypeDefault
trackerNameStringName—
Returns Reckfell.Collections.Array<Transform3D>
_GetCameraProjectionsReckfell.Collections.Array<Projection>
# _GetCameraProjections
C#
public virtual Reckfell.Collections.Array<Projection> _GetCameraProjections(StringName trackerName, double aspect, double zNear, double zFar);

Returns an array of projections for each view rendered for the given camera, if this camera is handled by this extension. tracker_name refers to the camera tracker for which we're retrieving this.

Parameters
NameTypeDefault
trackerNameStringName—
aspectdouble—
zNeardouble—
zFardouble—
Returns Reckfell.Collections.Array<Projection>
_GetCompositionLayerulong
# _GetCompositionLayer
C#
public virtual ulong _GetCompositionLayer(int index);

Returns a pointer to an XrCompositionLayerBaseHeader struct to provide the given composition layer. This will only be called if the extension previously registered itself with OpenXRApiExtension.RegisterCompositionLayerProvider. Note: This virtual method will be called on the render thread. Additionally, the data it returns will be used shortly after this method is called, so it needs to remain valid until the next time OpenXRExtensionWrapper._OnPreRender runs.

Parameters
NameTypeDefault
indexint—
Returns ulong
_GetCompositionLayerCountint
# _GetCompositionLayerCount
C#
public virtual int _GetCompositionLayerCount();

Returns the number of composition layers this extension wrapper provides via OpenXRExtensionWrapper._GetCompositionLayer. This will only be called if the extension previously registered itself with OpenXRApiExtension.RegisterCompositionLayerProvider. Note: This virtual method will be called on the render thread. Additionally, the data it returns will be used shortly after this method is called, so it needs to remain valid until the next time OpenXRExtensionWrapper._OnPreRender runs.

Returns int
_GetCompositionLayerOrderint
# _GetCompositionLayerOrder
C#
public virtual int _GetCompositionLayerOrder(int index);

Returns an integer that will be used to sort the given composition layer provided via OpenXRExtensionWrapper._GetCompositionLayer. Lower numbers will move the layer to the front of the list, and higher numbers to the end. The default projection layer has an order of 0, so layers provided by this method should probably be above or below (but not exactly) 0. This will only be called if the extension previously registered itself with OpenXRApiExtension.RegisterCompositionLayerProvider. Note: This virtual method will be called on the render thread. Additionally, the data it returns will be used shortly after this method is called, so it needs to remain valid until the next time OpenXRExtensionWrapper._OnPreRender runs.

Parameters
NameTypeDefault
indexint—
Returns int
_GetRequestedExtensionsReckfell.Collections.Dictionary
# _GetRequestedExtensions
C#
public virtual Reckfell.Collections.Dictionary _GetRequestedExtensions(ulong xRVersion);

Returns a Reckfell.Collections.Dictionary of OpenXR extensions related to this extension. xr_version specifies the OpenXR version we're instantiating. This will be zero if the editor requests this list to flag supported features. The Reckfell.Collections.Dictionary should contain the name of the extension, mapped to a bool * cast to an integer:

  • If the bool * is a nullptr this extension is mandatory.
  • If the bool * points to a boolean, the boolean will be updated to true if the extension is enabled.
Parameters
NameTypeDefault
xRVersionulong—
Returns Reckfell.Collections.Dictionary
_GetSuggestedTrackerNamesstring[]
# _GetSuggestedTrackerNames
C#
public virtual string[] _GetSuggestedTrackerNames();

Returns a string[] of positional tracker names that are used within the extension wrapper.

Returns string[]
_GetViewportCompositionLayerExtensionPropertiesReckfell.Collections.Array<Reckfell.Collections.Dictionary>
# _GetViewportCompositionLayerExtensionProperties
C#
public virtual Reckfell.Collections.Array<Reckfell.Collections.Dictionary> _GetViewportCompositionLayerExtensionProperties();

Gets an array of Reckfell.Collections.Dictionarys that represent properties, just like ReckfellObject.GetPropertyList, that will be added to OpenXRCompositionLayer nodes. Note: This virtual method will be called on the render thread.

Returns Reckfell.Collections.Array<Reckfell.Collections.Dictionary>
_GetViewportCompositionLayerExtensionPropertyDefaultsReckfell.Collections.Dictionary
# _GetViewportCompositionLayerExtensionPropertyDefaults
C#
public virtual Reckfell.Collections.Dictionary _GetViewportCompositionLayerExtensionPropertyDefaults();

Gets a Reckfell.Collections.Dictionary containing the default values for the properties returned by OpenXRExtensionWrapper._GetViewportCompositionLayerExtensionProperties.

Returns Reckfell.Collections.Dictionary
_OnBeforeInstanceCreatedvoid
# _OnBeforeInstanceCreated
C#
public virtual void _OnBeforeInstanceCreated();

Called before the OpenXR instance is created. Note: This virtual method will be called on the main thread, however, it will be called before OpenXR becomes involved in rendering, so it is safe to write to data that will be used by the render thread.

_OnInstanceCreatedvoid
# _OnInstanceCreated
C#
public virtual void _OnInstanceCreated(ulong instance);

Called right after the OpenXR instance is created. Note: This virtual method will be called on the main thread, however, it will be called before OpenXR becomes involved in rendering, so it is safe to write to data that will be used by the render thread.

Parameters
NameTypeDefault
instanceulong—
_OnInstanceDestroyedvoid
# _OnInstanceDestroyed
C#
public virtual void _OnInstanceDestroyed();

Called right before the OpenXR instance is destroyed. Note: This virtual method will be called on the main thread, however, it will be called after OpenXR is done being involved in rendering, so it is safe to write to data that was used by the render thread.

_OnMainSwapchainsCreatedvoid
# _OnMainSwapchainsCreated
C#
public virtual void _OnMainSwapchainsCreated();

Called right after the main swapchains are (re)created. Note: This virtual method will be called on the render thread.

_OnPostDrawViewportvoid
# _OnPostDrawViewport
C#
public virtual void _OnPostDrawViewport(Rid viewport);

Called right after the given viewport is rendered. Note: The draw commands might only be queued at this point, not executed. Note: This virtual method will be called on the render thread.

Parameters
NameTypeDefault
viewportRid—
_OnPreDrawViewportvoid
# _OnPreDrawViewport
C#
public virtual void _OnPreDrawViewport(Rid viewport);

Called right before the given viewport is rendered. Note: This virtual method will be called on the render thread.

Parameters
NameTypeDefault
viewportRid—
_OnPreRendervoid
# _OnPreRender
C#
public virtual void _OnPreRender();

Called right before the XR viewports begin their rendering step. Note: This virtual method will be called on the render thread.

_OnProcessvoid
# _OnProcess
C#
public virtual void _OnProcess();

Called as part of the OpenXR process handling. This happens right before general and physics processing steps of the main loop. During this step controller data is queried and made available to game logic.

_OnRegisterMetadatavoid
# _OnRegisterMetadata
C#
public virtual void _OnRegisterMetadata(OpenXRInteractionProfileMetadata interactionProfileMetadata);

Allows extensions to register additional controller metadata. This function is called even when the OpenXR API is not constructed as the metadata needs to be available to the editor. Extensions should also provide metadata regardless of whether they are supported on the host system. The controller data is used to setup action maps for users who may have access to the relevant hardware.

Parameters
NameTypeDefault
interactionProfileMetadataOpenXRInteractionProfileMetadata—
_OnSessionCreatedvoid
# _OnSessionCreated
C#
public virtual void _OnSessionCreated(ulong session);

Called right after the OpenXR session is created. Note: This virtual method will be called on the main thread, however, it will be called before OpenXR becomes involved in rendering, so it is safe to write to data that will be used by the render thread.

Parameters
NameTypeDefault
sessionulong—
_OnSessionDestroyedvoid
# _OnSessionDestroyed
C#
public virtual void _OnSessionDestroyed();

Called right before the OpenXR session is destroyed. Note: This virtual method will be called on the main thread, however, it will be called after OpenXR is done being involved in rendering, so it is safe to write to data that was used by the render thread.

_OnStateExitingvoid
# _OnStateExiting
C#
public virtual void _OnStateExiting();

Called when the OpenXR session state is changed to exiting.

_OnStateFocusedvoid
# _OnStateFocused
C#
public virtual void _OnStateFocused();

Called when the OpenXR session state is changed to focused. This state is the active state when the game runs.

_OnStateIdlevoid
# _OnStateIdle
C#
public virtual void _OnStateIdle();

Called when the OpenXR session state is changed to idle.

_OnStateLossPendingvoid
# _OnStateLossPending
C#
public virtual void _OnStateLossPending();

Called when the OpenXR session state is changed to loss pending.

_OnStateReadyvoid
# _OnStateReady
C#
public virtual void _OnStateReady();

Called when the OpenXR session state is changed to ready. This means OpenXR is ready to set up the session.

_OnStateStoppingvoid
# _OnStateStopping
C#
public virtual void _OnStateStopping();

Called when the OpenXR session state is changed to stopping.

_OnStateSynchronizedvoid
# _OnStateSynchronized
C#
public virtual void _OnStateSynchronized();

Called when the OpenXR session state is changed to synchronized. OpenXR also returns to this state when the application loses focus.

_OnStateVisiblevoid
# _OnStateVisible
C#
public virtual void _OnStateVisible();

Called when the OpenXR session state is changed to visible. This means OpenXR is now ready to receive frames.

_OnSyncActionsvoid
# _OnSyncActions
C#
public virtual void _OnSyncActions();

Called when OpenXR has performed its action sync.

_PrepareViewConfigurationvoid
# _PrepareViewConfiguration
C#
public virtual void _PrepareViewConfiguration(int viewCount);

Called before _set_view_configuration_and_get_next_pointer to allow the extension to reserve data for the given number of views.

Parameters
NameTypeDefault
viewCountint—
_PrintViewConfigurationInfovoid
# _PrintViewConfigurationInfo
C#
public virtual void _PrintViewConfigurationInfo(int view);

Called to allow an extension to print additional information about its view configuration, if applicable. This will only be called if verbose output is enabled.

Parameters
NameTypeDefault
viewint—
Reckfell Engine documentationBack to top ↑
QUICK LINKSGetting startedEntity hierarchyC# & .NET 10Scenes and prefabs
Reckfell guides and full API K
reckfellENGINE
RECKFELL ACCOUNT

Sign in

Sign in to your Reckfell account.

One account for the entire Reckfell platform.