VTK  9.3.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 
43 VTK_ABI_NAMESPACE_BEGIN
44 class vtkMatrix4x4;
45 
46 class VTKRENDERINGOPENXR_EXPORT vtkOpenXRRenderWindow : public vtkVRRenderWindow
47 {
48 public:
49  static vtkOpenXRRenderWindow* New();
51 
56 
60  void AddRenderer(vtkRenderer*) override;
61 
66  void StereoUpdate() override;
67 
72  void StereoMidpoint() override;
73 
78  void StereoRenderComplete() override;
79 
84  void Render() override;
85 
92  void Initialize() override;
93 
99  void Finalize() override;
100 
104  const char* ReportCapabilities() override { return "OpenXR System"; }
105 
109  bool GetSizeFromAPI() override;
110 
116  vtkTypeBool GetEventPending() override { return 0; }
117 
121  void SetModelActiveState(const int hand, bool state) { this->ModelsActiveState[hand] = state; }
122 
123  uint32_t GetDeviceHandleForOpenXRHandle(uint32_t index);
124  vtkEventDataDevice GetDeviceForOpenXRHandle(uint32_t ohandle);
125 
131  void UpdateHMDMatrixPose() override;
132 
136  void RenderModels() override;
137 
138 protected:
140  ~vtkOpenXRRenderWindow() override;
141 
142  // Create one framebuffer per view
143  bool CreateFramebuffers(uint32_t viewCount = 2) override;
144 
145  bool BindTextureToFramebuffer(FramebufferDesc& framebufferDesc);
146  void RenderFramebuffer(FramebufferDesc& framebufferDesc) override;
147 
148  virtual void RenderOneEye(uint32_t eye);
149 
151 
152  // Store if a model is active or not here as openxr do not have a concept
153  // of active/inactive controller
154  std::array<bool, 2> ModelsActiveState = { true, true };
155 
156 private:
158  void operator=(const vtkOpenXRRenderWindow&) = delete;
159 };
160 
161 VTK_ABI_NAMESPACE_END
162 #endif
163 // VTK-HeaderTest-Exclude: vtkOpenXRRenderWindow.h
virtual void RenderFramebuffer(FramebufferDesc &framebufferDesc)=0
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:30
virtual void RenderModels()=0
Render the controller and base station models.
static vtkRenderWindow * New()
Construct an instance of vtkRenderWindow with its screen size set to 300x300, borders turned on...
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:61
vtkRenderWindowInteractor * MakeRenderWindowInteractor() override=0
Create an interactor to control renderers in this window.
virtual void Finalize()
Finalize the rendering process.
virtual bool CreateFramebuffers(uint32_t viewCount=2)=0
int vtkTypeBool
Definition: vtkABI.h:64
platform-independent render window interaction including picking and frame rate control.
const char * ReportCapabilities() override
Get report of capabilities for the render window.
virtual void StereoUpdate()
Update the system, if needed, due to stereo rendering.
virtual void Initialize()
Initialize the rendering window.
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.
virtual void UpdateHMDMatrixPose()
Update the HMD pose.
void StereoMidpoint() override
Intermediate method performs operations required between the rendering of the left and right eye...
OpenXR rendering window.