VTK  9.7.20260805
vtkOpenXRRenderWindow.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2// SPDX-License-Identifier: BSD-3-Clause
32
33#ifndef vtkOpenXRRenderWindow_h
34#define vtkOpenXRRenderWindow_h
35
36#include "vtkRenderingOpenXRModule.h" // For export macro
37#include "vtkVRRenderWindow.h"
38
39#include "vtkEventData.h" // for method sig
40
41#include <array> // array
42#include <cstdint> // uint32_t
43#include <memory> // unique_ptr
44#include <string> // string
45
46VTK_ABI_NAMESPACE_BEGIN
47
48class vtkMatrix4x4;
51
52class VTKRENDERINGOPENXR_EXPORT vtkOpenXRRenderWindow : public vtkVRRenderWindow
53{
54public:
57
62
66 void AddRenderer(vtkRenderer*) override;
67
72 void StereoUpdate() override;
73
78 void StereoMidpoint() override;
79
84 void StereoRenderComplete() override;
85
90 void Render() override;
91
98 void Initialize() override;
99
105 void Finalize() override;
106
110 const char* ReportCapabilities() override { return "OpenXR System"; }
111
115 bool GetSizeFromAPI() override;
116
122 vtkTypeBool GetEventPending() override { return 0; }
123
127 void SetModelActiveState(const int hand, bool state) { this->ModelsActiveState[hand] = state; }
128
129 uint32_t GetDeviceHandleForOpenXRHandle(uint32_t index);
131
137 void UpdateHMDMatrixPose() override;
138
142 void RenderModels() override;
143
147 std::string& GetCurrentInteractionProfile(uint32_t);
148 void SetCurrentInteractionProfile(uint32_t, const std::string& profile);
149
151
157 void SetModelsManifestDirectory(const std::string& path);
159
161
180 vtkSetMacro(UseDepthExtension, bool);
181 vtkGetMacro(UseDepthExtension, bool);
183
185
198 vtkSetMacro(EnableSceneUnderstanding, bool);
199 vtkGetMacro(EnableSceneUnderstanding, bool);
201
213
217 struct VTKRENDERINGOPENXR_EXPORT InstanceVersion
218 {
219 std::uint16_t Major{};
220 std::uint16_t Minor{};
221 std::uint32_t Patch{};
222 };
223
230
231protected:
234
235 // Create one framebuffer per view
236 bool CreateFramebuffers(uint32_t viewCount = 2) override;
237
239 void RenderFramebuffer(FramebufferDesc& framebufferDesc) override;
240
241 virtual void RenderOneEye(uint32_t eye);
242
244
245 // Store if a model is active or not here as openxr do not have a concept
246 // of active/inactive controller
247 std::array<bool, 2> ModelsActiveState = { true, true };
248
249private:
251 void operator=(const vtkOpenXRRenderWindow&) = delete;
252
253 class vtkInternals;
254 std::unique_ptr<vtkInternals> Internal;
255
256 bool UseDepthExtension = false;
257 bool EnableSceneUnderstanding = false;
258};
259
260VTK_ABI_NAMESPACE_END
261#endif
262// VTK-HeaderTest-Exclude: vtkOpenXRRenderWindow.h
represent and manipulate 4x4 transformation matrices
Allocate and hold a VTK object.
Definition vtkNew.h:59
OpenXR manager connection no-op implementation.
OpenXR rendering window.
std::string & GetModelsManifestDirectory()
Get/Set a custom path to look for the controllers models.
static vtkOpenXRRenderWindow * New()
vtkOpenXRSceneObserver * GetSceneObserver()
Returns scene observer associated with this window.
void SetModelsManifestDirectory(const std::string &path)
Get/Set a custom path to look for the controllers models.
void SetCurrentInteractionProfile(uint32_t, const std::string &profile)
void RenderFramebuffer(FramebufferDesc &framebufferDesc) override
void Render() override
Overridden to not release resources that would interfere with an external application's rendering.
void StereoUpdate() override
Update the system, if needed, due to stereo rendering.
std::array< bool, 2 > ModelsActiveState
~vtkOpenXRRenderWindow() override
virtual void RenderOneEye(uint32_t eye)
static InstanceVersion QueryInstanceVersion(vtkOpenXRManagerConnection *cs)
Utility function to get XrInstance runtime version for the given ConnectionStrategy.
std::string & GetCurrentInteractionProfile(uint32_t)
Get/Set the current interaction profile for a hand.
bool BindTextureToFramebuffer(FramebufferDesc &framebufferDesc)
vtkTypeBool GetEventPending() override
Check to see if a mouse button has been pressed or mouse wheel activated.
void AddRenderer(vtkRenderer *) override
Add a renderer to the list of renderers.
const char * ReportCapabilities() override
Get report of capabilities for the render window.
bool CreateFramebuffers(uint32_t viewCount=2) override
void Finalize() override
Finalize the rendering window.
vtkRenderWindowInteractor * MakeRenderWindowInteractor() override
Create an interactor to control renderers in this window.
void UpdateHMDMatrixPose() override
Update the HMD pose based on hardware pose and physical to world transform.
void StereoRenderComplete() override
Handles work required once both views have been rendered when using stereo rendering.
void SetModelActiveState(const int hand, bool state)
Set the active state (active: true / inactive: false) of the specified hand.
void Initialize() override
Initialize the rendering window.
uint32_t GetDeviceHandleForOpenXRHandle(uint32_t index)
vtkEventDataDevice GetDeviceForOpenXRHandle(uint32_t ohandle)
vtkNew< vtkMatrix4x4 > TempMatrix4x4
void StereoMidpoint() override
Intermediate method performs operations required between the rendering of the left and right eye.
bool GetSizeFromAPI() override
Get size of render window from OpenXR.
void RenderModels() override
Render the controllers.
vtkOpenXRSceneObserver is a wrapper around OpenXR scene understanding extensions
platform-independent render window interaction including picking and frame rate control.
abstract specification for renderers
Definition vtkRenderer.h:64
Structure representing OpenXR instance version.
int vtkTypeBool
Definition vtkABI.h:64
vtkEventDataDevice
platform-independent event data structures
#define VTK_NEWINSTANCE