25 #ifndef vtkOpenXRManager_h
26 #define vtkOpenXRManager_h
28 #include "vtkRenderingOpenXRModule.h"
50 return UniqueInstance;
59 bool XrCheckError(
const XrResult&,
const std::string& message);
67 bool XrCheckWarn(
const XrResult&,
const std::string& message);
74 void PrintInstanceProperties();
75 void PrintSystemProperties(XrSystemProperties* system_properties);
76 void PrintSupportedViewConfigs();
77 void PrintViewConfigViewInfo(
const std::vector<XrViewConfigurationView>&);
78 bool PrintReferenceSpaces();
101 std::tuple<uint32_t, uint32_t> GetRecommendedImageRectSize();
109 return static_cast<uint32_t
>(this->RenderResources->ConfigViews.size());
129 if (eye >= this->GetViewCount())
133 return &(this->RenderResources->Views[eye].pose);
145 if (eye >= this->GetViewCount())
149 return &(this->RenderResources->Views[eye].fov);
205 bool WaitAndBeginFrame();
215 bool PrepareRendering(uint32_t eye, GLuint& colorTextureId, GLuint& depthTextureId);
223 void ReleaseSwapchainImage(uint32_t eye);
238 bool PollEvent(XrEventDataBuffer& eventData);
262 bool SelectActiveActionSet(
unsigned int index);
269 bool AttachSessionActionSets();
277 void DestroyActionSets();
287 bool CreateOneAction(
296 const std::string&
profile, std::vector<XrActionSuggestedBinding>& actionSuggestedBindings);
315 bool UpdateActionData(
Action_t& action_t,
const int hand);
323 bool ApplyVibration(
const Action_t& actionT,
const int hand,
const float amplitude = 0.5f,
324 const float duration = 25000000.0f,
const float frequency = XR_FREQUENCY_UNSPECIFIED);
333 NumberOfControllers = 4
346 } States[ControllerIndex::NumberOfControllers];
348 XrSpace PoseSpaces[ControllerIndex::NumberOfControllers];
349 XrSpaceLocation PoseLocations[ControllerIndex::NumberOfControllers];
350 XrSpaceVelocity PoseVelocities[ControllerIndex::NumberOfControllers];
363 bool CreateInstance();
364 std::vector<const char*> SelectExtensions();
371 void PrintOptionalExtensions();
386 bool CheckGraphicsRequirements();
405 bool CreateSession();
413 bool CreateSwapchains();
421 bool CreateConfigViews();
432 std::tuple<int64_t, int64_t> SelectSwapchainPixelFormats();
433 const std::vector<int64_t>& GetSupportedColorFormats();
434 const std::vector<int64_t>& GetSupportedDepthFormats();
445 uint32_t sampleCount, XrSwapchainCreateFlags createFlags, XrSwapchainUsageFlags usageFlags);
452 bool CreateReferenceSpace();
455 bool LoadControllerModels();
461 bool CreateOneActionSpace(
const XrAction& action,
const XrPath& subactionPath,
462 const XrPosef& poseInActionSpace, XrSpace& space);
469 bool CreateSubactionPaths();
477 uint32_t WaitAndAcquireSwapchainImage(
const XrSwapchain& swapchainHandle);
481 constexpr
static XrFormFactor FormFactor = XR_FORM_FACTOR_HEAD_MOUNTED_DISPLAY;
484 constexpr
static XrViewConfigurationType ViewType = XR_VIEW_CONFIGURATION_TYPE_PRIMARY_STEREO;
487 constexpr
static uint32_t StereoViewCount = 2;
492 constexpr
static XrReferenceSpaceType ReferenceSpaceType = XR_REFERENCE_SPACE_TYPE_STAGE;
515 bool HasOpenGLExtension =
false;
524 bool DepthExtensionSupported{
false };
525 bool ControllerModelExtensionSupported{
false };
526 bool UnboundedRefSpaceSupported{
false };
527 bool SpatialAnchorSupported{
false };
528 bool HandTrackingSupported{
false };
529 } OptionalExtensions;
540 int64_t Format{ GL_NONE };
542 uint32_t Height{ 0 };
543 std::vector<XrSwapchainImageOpenGLKHR>
Images;
555 XrViewState ViewState{ XR_TYPE_VIEW_STATE };
567 std::unique_ptr<RenderResources_t> RenderResources{};
574 XrActionSet* ActiveActionSet =
nullptr;
582 bool SessionRunning =
false;
585 bool ShouldRenderCurrentFrame =
false;
588 bool StorePoseVelocities =
false;
std::shared_ptr< void > GraphicsBinding
This struct stores all needed information to render the images and send it to the user We can't make ...
XrActionStateVector2f _vec2f
static vtkOpenXRManager & GetInstance()
Return the singleton instance.
Singleton class that holds a collection of utility functions and member variables to communicate with...
XrSessionState SessionState
uint32_t GetViewCount()
Return the number of OpenXR views (typically one per physical display / eye)
const XrInstance & GetXrRuntimeInstance()
Return the instance used to communicate with the runtime.
bool IsDepthExtensionSupported()
Return true if the runtime supports the depth extension.
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.
Swapchain structure for OpenGL backend.
XrEnvironmentBlendMode EnvironmentBlendMode
XrActionStateFloat _float
std::vector< SwapchainOpenGL_t > DepthSwapchains
const std::array< XrPath, 2 > & GetSubactionPaths()
bool IsSessionRunning()
Return true if the OpenXR session is currently running, ie.
std::vector< XrSwapchainImageOpenGLKHR > Images
XrTime PredictedDisplayTime
Store the frame predicted display time in WaitAndBeginFrame To get the action data at this time and t...
std::vector< XrActionSet > ActionSets
XrActionStateBoolean _boolean
std::vector< XrView > Views
std::array< XrPath, 2 > SubactionPaths
const XrSession & GetSession()
Return the OpenXR Session.
std::vector< SwapchainOpenGL_t > ColorSwapchains
std::vector< XrViewConfigurationView > ConfigViews
std::vector< XrCompositionLayerDepthInfoKHR > DepthInfoViews
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...
xr::ExtensionDispatchTable Extensions
std::vector< XrCompositionLayerProjectionView > ProjectionLayerViews