VTK  9.7.1
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
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 
46 VTK_ABI_NAMESPACE_BEGIN
47 
48 class vtkMatrix4x4;
51 
52 class VTKRENDERINGOPENXR_EXPORT vtkOpenXRRenderWindow : public vtkVRRenderWindow
53 {
54 public:
55  static vtkOpenXRRenderWindow* New();
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);
130  vtkEventDataDevice GetDeviceForOpenXRHandle(uint32_t ohandle);
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 
156  std::string& GetModelsManifestDirectory();
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 
212  vtkOpenXRSceneObserver* GetSceneObserver();
213 
217  struct VTKRENDERINGOPENXR_EXPORT InstanceVersion
218  {
219  std::uint16_t Major{};
220  std::uint16_t Minor{};
221  std::uint32_t Patch{};
222  };
223 
229  static InstanceVersion QueryInstanceVersion(vtkOpenXRManagerConnection* cs);
230 
231 protected:
233  ~vtkOpenXRRenderWindow() override;
234 
235  // Create one framebuffer per view
236  bool CreateFramebuffers(uint32_t viewCount = 2) override;
237 
238  bool BindTextureToFramebuffer(FramebufferDesc& framebufferDesc);
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 
249 private:
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 
260 VTK_ABI_NAMESPACE_END
261 #endif
262 // VTK-HeaderTest-Exclude: vtkOpenXRRenderWindow.h
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:31
virtual void RenderModels()=0
Render the controller and base station models.
vtkNew< vtkMatrix4x4 > TempMatrix4x4
VR rendering window.
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.
abstract specification for renderers
Definition: vtkRenderer.h:63
vtkRenderWindowInteractor * MakeRenderWindowInteractor() override=0
Create an interactor to control renderers in this window.
virtual void Finalize()
Finalize the rendering process.
int vtkTypeBool
Definition: vtkABI.h:64
platform-independent render window interaction including picking and frame rate control.
static vtkOpenGLRenderWindow * New()
Structure representing OpenXR instance version.
const char * ReportCapabilities() override
Get report of capabilities for the render window.
void Initialize() override
Initialize the rendering window.
virtual void StereoUpdate()
Update the system, if needed, due to stereo rendering.
vtkEventDataDevice
platform-independent event data structures
Definition: vtkEventData.h:14
virtual bool GetSizeFromAPI()=0
Attempt to get the size of the display from the API and store it in this->Size.
#define VTK_NEWINSTANCE
void SetModelActiveState(const int hand, bool state)
Set the active state (active: true / inactive: false) of the specified hand.
void Render() override
Overridden to not release resources that would interfere with an external application's rendering...
virtual void StereoRenderComplete()
Handles work required once both views have been rendered when using stereo rendering.
OpenXR manager connection no-op implementation.
virtual void UpdateHMDMatrixPose()
Update the HMD pose.
vtkOpenXRSceneObserver is a wrapper around OpenXR scene understanding extensions
void StereoMidpoint() override
Intermediate method performs operations required between the rendering of the left and right eye...
OpenXR rendering window.