VTK  9.2.6
vtkOpenXRRenderWindow.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3 Program: Visualization Toolkit
4 
5 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
6 All rights reserved.
7 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without even
10 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11 PURPOSE. See the above copyright notice for more information.
12 
13 =========================================================================*/
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 #include "vtkOpenXR.h"
60 
61 #include <array> // array
62 
63 class vtkMatrix4x4;
64 
65 class VTKRENDERINGOPENXR_EXPORT vtkOpenXRRenderWindow : public vtkVRRenderWindow
66 {
67 public:
68  static vtkOpenXRRenderWindow* New();
70 
75 
79  void AddRenderer(vtkRenderer*) override;
80 
85  void StereoUpdate() override;
86 
91  void StereoMidpoint() override;
92 
97  void StereoRenderComplete() override;
98 
103  void Render() override;
105 
107 
113  void Initialize() override;
114 
120  void Finalize() override;
121 
125  const char* ReportCapabilities() override { return "OpenXR System"; }
126 
130  bool GetSizeFromAPI() override;
131 
137  vtkTypeBool GetEventPending() override { return 0; }
138 
140 
143  void SetModelActiveState(const int hand, bool state) { this->ModelsActiveState[hand] = state; }
145 
146  uint32_t GetDeviceHandleForOpenXRHandle(uint32_t index);
147  vtkEventDataDevice GetDeviceForOpenXRHandle(uint32_t ohandle);
148 
154  void UpdateHMDMatrixPose() override;
155 
156 protected:
158  ~vtkOpenXRRenderWindow() override;
159 
160  // Create one framebuffer per view
161  bool CreateFramebuffers(uint32_t viewCount = 2) override;
162 
163  bool BindTextureToFramebuffer(FramebufferDesc& framebufferDesc);
164  void RenderFramebuffer(FramebufferDesc& framebufferDesc);
165 
166  void RenderOneEye(const uint32_t eye);
167 
168  void RenderModels();
169 
171 
172  // Store if a model is active or not here as openxr do not have a concept
173  // of active/inactive controller
174  std::array<bool, 2> ModelsActiveState = { true, true };
175 
176 private:
178  void operator=(const vtkOpenXRRenderWindow&) = delete;
179 };
180 
181 #endif
182 // VTK-HeaderTest-Exclude: vtkOpenXRRenderWindow.h
void RenderFramebuffer(FramebufferDesc &framebufferDesc)
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:41
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:72
vtkRenderWindowInteractor * MakeRenderWindowInteractor() override=0
Create an interactor to control renderers in this window.
virtual bool CreateFramebuffers(uint32_t viewCount=2)=0
int vtkTypeBool
Definition: vtkABI.h:69
platform-independent render window interaction including picking and frame rate control.
const char * ReportCapabilities() override
Get report of capabilities for the render window.
void Finalize() override
Finalize the rendering window.
virtual void StereoUpdate()
Update the system, if needed, due to stereo rendering.
void Initialize() override
Initialize the rendering window.
vtkEventDataDevice
platform-independent event data structures
Definition: vtkEventData.h:25
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.