25#ifndef vtkOpenXRManager_h
26#define vtkOpenXRManager_h
28#include "vtkRenderingOpenXRModule.h"
50 return UniqueInstance;
67 bool XrCheckWarn(
const XrResult&,
const std::string& message);
109 return static_cast<uint32_t
>(this->
RenderResources->ConfigViews.size());
254 bool CreateActionSet(
const std::string& actionSetName,
const std::string& localizedActionSetName);
288 Action_t& actionT,
const std::string& name,
const std::string& localizedName);
296 const std::string& profile, std::vector<XrActionSuggestedBinding>& actionSuggestedBindings);
324 const float duration = 25000000.0f,
const float frequency = XR_FREQUENCY_UNSPECIFIED);
445 uint32_t sampleCount, XrSwapchainCreateFlags createFlags, XrSwapchainUsageFlags usageFlags);
462 const XrPosef& poseInActionSpace, XrSpace& space);
481 constexpr static XrFormFactor
FormFactor = XR_FORM_FACTOR_HEAD_MOUNTED_DISPLAY;
484 constexpr static XrViewConfigurationType
ViewType = XR_VIEW_CONFIGURATION_TYPE_PRIMARY_STEREO;
529 } OptionalExtensions;
543 std::vector<XrSwapchainImageOpenGLKHR>
Images;
const XrInstance & GetXrRuntimeInstance()
Return the instance used to communicate with the runtime.
void PrintViewConfigViewInfo(const std::vector< XrViewConfigurationView > &)
bool SpatialAnchorSupported
bool CreateOneActionSpace(const XrAction &action, const XrPath &subactionPath, const XrPosef &poseInActionSpace, XrSpace &space)
For pose actions, we must create an action space to locate it.
bool HandTrackingSupported
XrTime PredictedDisplayTime
Store the frame predicted display time in WaitAndBeginFrame To get the action data at this time and t...
bool Initialize(vtkOpenGLRenderWindow *)
Initialize the OpenXR SDK to render images in a virtual reality device.
bool BeginSession()
Start the OpenXR session.
void PrintOptionalExtensions()
Print the optional extensions which were found and enabled.
const XrPosef * GetViewPose(uint32_t eye)
Returns a pointer to the view pose that contains the view orientation and position for the specified ...
bool GetShouldRenderCurrentFrame()
Return true if the current frame should be rendered.
void PrintInstanceProperties()
Utility functions to print information about OpenXR manager internal structures.
static constexpr XrReferenceSpaceType ReferenceSpaceType
void PrintSystemProperties(XrSystemProperties *system_properties)
bool WaitAndBeginFrame()
This function is used to start a frame.
std::tuple< int64_t, int64_t > SelectSwapchainPixelFormats()
During the creation of the swapchains, we need to check the runtime available pixels formats,...
bool AttachSessionActionSets()
Attach all action sets in the ActionSets vector to the session.
~vtkOpenXRManager()=default
struct vtkOpenXRManager::@342253300264113136100372334253042337262164244010 OptionalExtensions
Structure to hold optional extensions loaded with SelectExtensions.
bool IsSessionRunning()
Return true if the OpenXR session is currently running, ie.
const XrFovf * GetProjectionFov(uint32_t eye)
Returns a pointer to the projection field of view for the specified eye, or nullptr if eye exceeds or...
bool CreateSystem()
OpenXR System creation.
bool CheckGraphicsRequirements()
OpenXR requires checking graphics requirements before creating a session.
bool CreateReferenceSpace()
Creates the reference space of type ReferenceSpaceType that will be used to locate views.
bool IsDepthExtensionSupported()
Return true if the runtime supports the depth extension.
std::tuple< uint32_t, uint32_t > GetRecommendedImageRectSize()
Return as a tuple the OpenXR recommended texture size to be sent to the device.
uint32_t GetViewCount()
Return the number of OpenXR views (typically one per physical display / eye)
bool UnboundedRefSpaceSupported
XrPath GetXrPath(const std::string &path)
Get the XrPath from the well-formed string path.
uint32_t WaitAndAcquireSwapchainImage(const XrSwapchain &swapchainHandle)
When preparing the rendering for an eye, we must ask the runtime for a texture to draw in it.
bool ShouldRenderCurrentFrame
bool EndFrame()
Submit the composition layers for the predicted display time of the current frame.
bool CreateInstance()
OpenXR Instance creation.
bool PollEvent(XrEventDataBuffer &eventData)
Store in eventData the result of xrPollEvent.
xr::ExtensionDispatchTable Extensions
static vtkOpenXRManager & GetInstance()
Return the singleton instance.
bool CreateOneAction(Action_t &actionT, const std::string &name, const std::string &localizedName)
Creates one action with name name and localizedName localizedName and store the action handle inside ...
XrActionSet * ActiveActionSet
std::array< XrPath, 2 > SubactionPaths
vtkOpenXRManager()=default
bool SyncActions()
Update the action states using the active action set.
bool CreateGraphicsBinding(vtkOpenGLRenderWindow *helperWindow)
Create the graphics binding and store it in GraphicsBindings ptr.
const std::vector< int64_t > & GetSupportedColorFormats()
bool CreateActionSet(const std::string &actionSetName, const std::string &localizedActionSetName)
Creates an action set and add it to the vector of action sets.
bool XrCheckWarn(const XrResult &, const std::string &message)
Utility function to check the XrResult, print the result message and raise a warning if the result fa...
bool ControllerModelExtensionSupported
std::string GetOpenXRPropertiesAsString()
Return the OpenXR properties as a string, with format "RuntimeName MAJOR.MINOR.PATCH".
void Finalize()
End the OpenXR session and destroy it and the OpenXR instance.
void ReleaseSwapchainImage(uint32_t eye)
When the rendering in a swapchain image is done, it must be released with this function.
bool SelectActiveActionSet(unsigned int index)
Selects the current active action set from the ActionSets vector using its index.
bool CreateConfigViews()
There is one configuration view per view, and it contains the recommended texture resolution in pixel...
XrSessionState SessionState
std::shared_ptr< void > GraphicsBinding
bool ApplyVibration(const Action_t &actionT, const int hand, const float amplitude=0.5f, const float duration=25000000.0f, const float frequency=XR_FREQUENCY_UNSPECIFIED)
Apply haptic vibration action to emit vibration on hand to emit on amplitude 0.0 to 1....
bool CreateSwapchains()
Swapchaines creation : there is one swapchain per view / display.
void DestroyActionSets()
Iterate over and destroy all action sets that have been created.
bool UpdateActionData(Action_t &action_t, const int hand)
Update the action data and store it in action_t.States for one hand.
bool CreateSession()
Create the session and pass the GraphicsBinding to the next pointer of the XrSessionCreateInfo.
std::vector< XrActionSet > ActionSets
const std::vector< int64_t > & GetSupportedDepthFormats()
SwapchainOpenGL_t CreateSwapchainOpenGL(int64_t format, uint32_t width, uint32_t height, uint32_t sampleCount, XrSwapchainCreateFlags createFlags, XrSwapchainUsageFlags usageFlags)
Create an XrSwapchain handle used to present rendered image to the user with the given parameters for...
const XrSession & GetSession()
Return the OpenXR Session.
void PrintSupportedViewConfigs()
const std::array< XrPath, 2 > & GetSubactionPaths()
XrEnvironmentBlendMode EnvironmentBlendMode
bool LoadControllerModels()
bool SuggestActions(const std::string &profile, std::vector< XrActionSuggestedBinding > &actionSuggestedBindings)
Suggest actions stored in actionSuggestedBindings for the interaction profile profile.
bool CreateSubactionPaths()
Creates one subaction path for each hand.
bool DepthExtensionSupported
static constexpr XrFormFactor FormFactor
bool PrintReferenceSpaces()
bool PrepareRendering(uint32_t eye, GLuint &colorTextureId, GLuint &depthTextureId)
Prepare the rendering resources for the specified eye and store in colorTextureId and in depthTexture...
std::unique_ptr< RenderResources_t > RenderResources
static constexpr uint32_t StereoViewCount
std::vector< const char * > SelectExtensions()
static constexpr XrViewConfigurationType ViewType
bool XrCheckError(const XrResult &, const std::string &message)
Utility function to check the XrResult, print the result message and raise an error if the result fai...
XrActionStateFloat _float
XrSpace PoseSpaces[ControllerIndex::NumberOfControllers]
XrSpaceVelocity PoseVelocities[ControllerIndex::NumberOfControllers]
XrActionStateVector2f _vec2f
XrActionStateBoolean _boolean
XrSpaceLocation PoseLocations[ControllerIndex::NumberOfControllers]
This struct stores all needed information to render the images and send it to the user We can't make ...
std::vector< XrView > Views
std::vector< XrViewConfigurationView > ConfigViews
std::vector< SwapchainOpenGL_t > DepthSwapchains
std::vector< XrCompositionLayerProjectionView > ProjectionLayerViews
std::vector< SwapchainOpenGL_t > ColorSwapchains
std::vector< XrCompositionLayerDepthInfoKHR > DepthInfoViews
Swapchain structure for OpenGL backend.
std::vector< XrSwapchainImageOpenGLKHR > Images