VTK  9.6.20260511
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
51
52#ifndef vtkOpenXRRenderWindow_h
53#define vtkOpenXRRenderWindow_h
54
55#include "vtkRenderingOpenXRModule.h" // For export macro
56#include "vtkVRRenderWindow.h"
57
58#include "vtkEventData.h" // for method sig
59
60#include <array> // array
61#include <cstdint> // uint32_t
62#include <memory> // unique_ptr
63#include <string> // string
64
65VTK_ABI_NAMESPACE_BEGIN
66
67class vtkMatrix4x4;
70
71class VTKRENDERINGOPENXR_EXPORT vtkOpenXRRenderWindow : public vtkVRRenderWindow
72{
73public:
76
81
85 void AddRenderer(vtkRenderer*) override;
86
91 void StereoUpdate() override;
92
97 void StereoMidpoint() override;
98
103 void StereoRenderComplete() override;
104
109 void Render() override;
110
117 void Initialize() override;
118
124 void Finalize() override;
125
129 const char* ReportCapabilities() override { return "OpenXR System"; }
130
134 bool GetSizeFromAPI() override;
135
141 vtkTypeBool GetEventPending() override { return 0; }
142
146 void SetModelActiveState(const int hand, bool state) { this->ModelsActiveState[hand] = state; }
147
148 uint32_t GetDeviceHandleForOpenXRHandle(uint32_t index);
150
156 void UpdateHMDMatrixPose() override;
157
161 void RenderModels() override;
162
166 std::string& GetCurrentInteractionProfile(uint32_t);
167 void SetCurrentInteractionProfile(uint32_t, const std::string& profile);
168
170
176 void SetModelsManifestDirectory(const std::string& path);
178
180
199 vtkSetMacro(UseDepthExtension, bool);
200 vtkGetMacro(UseDepthExtension, bool);
202
204
217 vtkSetMacro(EnableSceneUnderstanding, bool);
218 vtkGetMacro(EnableSceneUnderstanding, bool);
220
232
236 struct VTKRENDERINGOPENXR_EXPORT InstanceVersion
237 {
238 std::uint16_t Major{};
239 std::uint16_t Minor{};
240 std::uint32_t Patch{};
241 };
242
249
250protected:
253
254 // Create one framebuffer per view
255 bool CreateFramebuffers(uint32_t viewCount = 2) override;
256
258 void RenderFramebuffer(FramebufferDesc& framebufferDesc) override;
259
260 virtual void RenderOneEye(uint32_t eye);
261
263
264 // Store if a model is active or not here as openxr do not have a concept
265 // of active/inactive controller
266 std::array<bool, 2> ModelsActiveState = { true, true };
267
268private:
270 void operator=(const vtkOpenXRRenderWindow&) = delete;
271
272 class vtkInternals;
273 std::unique_ptr<vtkInternals> Internal;
274
275 bool UseDepthExtension = false;
276 bool EnableSceneUnderstanding = false;
277};
278
279VTK_ABI_NAMESPACE_END
280#endif
281// VTK-HeaderTest-Exclude: vtkOpenXRRenderWindow.h
represent and manipulate 4x4 transformation matrices
Allocate and hold a VTK object.
Definition vtkNew.h:168
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
Structure representing OpenXR instance version.
int vtkTypeBool
Definition vtkABI.h:64
vtkEventDataDevice
platform-independent event data structures
#define VTK_NEWINSTANCE