VTK
vtkOpenVRRenderWindow.h
Go to the documentation of this file.
1/*=========================================================================
2
3Program: Visualization Toolkit
4
5Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
6All rights reserved.
7See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
8
9This software is distributed WITHOUT ANY WARRANTY; without even
10the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11PURPOSE. See the above copyright notice for more information.
12
13=========================================================================*/
42#ifndef vtkOpenVRRenderWindow_h
43#define vtkOpenVRRenderWindow_h
44
45#include "vtkRenderingOpenVRModule.h" // For export macro
46#include "vtkOpenGLRenderWindow.h"
47
48#define SDL_MAIN_HANDLED
49#include <SDL.h> // for ivars
50#include <openvr.h> // for ivars
51#include <vector> // ivars
52#include "vtkOpenGLHelper.h" // used for ivars
53#include "vtk_glew.h" // used for methods
54
55class vtkOpenVRModel;
57class vtkTransform;
58
59class VTKRENDERINGOPENVR_EXPORT vtkOpenVRRenderWindow : public vtkOpenGLRenderWindow
60{
61public:
64 void PrintSelf(ostream& os, vtkIndent indent);
65
69 virtual void Start(void);
70
75 virtual void StereoUpdate();
76
81 virtual void StereoMidpoint();
82
87 virtual void StereoRenderComplete();
88
92 void Frame(void);
93
100 virtual void Initialize(void);
101
107 virtual void Finalize(void);
108
113
117 virtual bool IsCurrent();
118
122 const char *ReportCapabilities() { return "OpenVR System";};
123
127 int IsDirect() { return 1; };
128
134 virtual int GetEventPending() { return 0;};
135
139 void Clean();
140
144 virtual int *GetScreenSize();
145
147
150 virtual void SetSize(int,int);
151 virtual void SetSize(int a[2]) {vtkOpenGLRenderWindow::SetSize(a);};
153
155
158 virtual void SetPosition(int,int);
161
162 // implement required virtual functions
163 void SetWindowInfo(char *) {};
164 void SetNextWindowInfo(char *) {};
165 void SetParentInfo(char *) {};
166 virtual void *GetGenericDisplayId() {return (void *)this->ContextId;};
167 virtual void *GetGenericWindowId() {return (void *)this->WindowId;};
168 virtual void *GetGenericParentId() {return (void *)NULL;};
169 virtual void *GetGenericContext() {return (void *)this->ContextId;};
170 virtual void *GetGenericDrawable() {return (void *)this->WindowId;};
171 virtual void SetDisplayId(void *) {};
172 void SetWindowId(void *) {};
173 void SetParentId(void *) {};
174 void HideCursor() {};
175 void ShowCursor() {};
176 virtual void SetFullScreen(int) {};
177 virtual void WindowRemap(void) {};
178 virtual void SetNextWindowId(void *) {};
179
183 vr::IVRSystem *GetHMD() { return this->HMD; };
184
189
193 virtual int SupportsOpenGL() { return 1; };
194
196
200 { return this->LeftEyeDesc.m_nRenderFramebufferId; };
202 { return this->LeftEyeDesc.m_nResolveFramebufferId; };
204 { return this->RightEyeDesc.m_nRenderFramebufferId; };
206 { return this->RightEyeDesc.m_nResolveFramebufferId; };
207 void GetRenderBufferSize(int &width, int &height) {
208 width = this->RenderWidth; height = this->RenderHeight; };
210
215 void Render();
216
220 vr::TrackedDevicePose_t &GetTrackedDevicePose(vr::TrackedDeviceIndex_t idx) {
221 return this->TrackedDevicePose[idx]; };
222
223protected:
226
232
233 virtual void CreateAWindow() {};
234 virtual void DestroyWindow() {};
235
236 SDL_Window *WindowId;
237 SDL_GLContext ContextId;
240 vr::IVRSystem *HMD;
241 vr::IVRRenderModels *OpenVRRenderModels;
242
244 {
250 };
253 bool CreateFrameBuffer( int nWidth, int nHeight,
254 FramebufferDesc &framebufferDesc );
255
256 // resolution to render to for FBOs
257 // (as opposed to the window)
258 uint32_t RenderWidth;
259 uint32_t RenderHeight;
260
262
270
271 // convert a device index to a human string
273 vr::IVRSystem *pHmd,
274 vr::TrackedDeviceIndex_t unDevice,
275 vr::TrackedDeviceProperty prop,
276 vr::TrackedPropertyError *peError = NULL );
277
278 // devices may have polygonal models
279 // load them
280 vtkOpenVRModel *FindOrLoadRenderModel(const char *modelName );
282 std::vector<vtkOpenVRModel * > VTKRenderModels;
283 vtkOpenVRModel *TrackedDeviceToRenderModel[ vr::k_unMaxTrackedDeviceCount ];
284 vr::TrackedDevicePose_t TrackedDevicePose[ vr::k_unMaxTrackedDeviceCount ];
285
286 // used in computing the pose
288
289private:
290 vtkOpenVRRenderWindow(const vtkOpenVRRenderWindow&); // Not implemented.
291 void operator=(const vtkOpenVRRenderWindow&); // Not implemented.
292};
293
294
295#endif
a simple class to control print indentation
Definition: vtkIndent.h:40
OpenGL rendering window.
virtual void SetSize(int a[2])
Set the size of the window in screen coordinates in pixels.
OpenVR rendering window.
virtual void SetSize(int a[2])
Set the size of the window in screen coordinates in pixels.
void HideCursor()
Hide or Show the mouse cursor, it is nice to be able to hide the default cursor if you want VTK to di...
void SetupDistortion()
Handle lens distortion.
vr::IVRSystem * GetHMD()
Get the system pointer.
virtual bool IsCurrent()
Tells if this window is the current OpenGL context for the calling thread.
void Clean()
Clean up device contexts, rendering contexts, etc.
static vtkOpenVRRenderWindow * New()
void Frame(void)
End the rendering process and display the image.
void PrintSelf(ostream &os, vtkIndent indent)
Methods invoked by print to print information about the object including superclasses.
virtual void DestroyWindow()
Destroy a not-off-screen window.
bool CreateFrameBuffer(int nWidth, int nHeight, FramebufferDesc &framebufferDesc)
virtual void * GetGenericParentId()
virtual void ReleaseGraphicsResources(vtkRenderWindow *)
Free up any graphics resources associated with this window a value of NULL means the context may alre...
virtual void StereoUpdate()
Update the system, if needed, due to stereo rendering.
virtual void CreateAWindow()
Create a not-off-screen window.
virtual void Finalize(void)
Finalize the rendering window.
void Render()
Overridden to not release resources that would interfere with an external application's rendering.
void UpdateHMDMatrixPose()
Update the HMD pose.
virtual void * GetGenericWindowId()
virtual void StereoRenderComplete()
Handles work required once both views have been rendered when using stereo rendering.
virtual void SetPosition(int, int)
Set the position of the window.
vr::TrackedDevicePose_t & GetTrackedDevicePose(vr::TrackedDeviceIndex_t idx)
Get the most recent pose of any tracked devices.
vtkOpenVRModel * FindOrLoadRenderModel(const char *modelName)
virtual int SupportsOpenGL()
Does this render window support OpenGL? 0-false, 1-true.
std::vector< vtkOpenVRModel * > VTKRenderModels
virtual void Start(void)
Begin the rendering process.
virtual void * GetGenericDrawable()
const char * ReportCapabilities()
Get report of capabilities for the render window.
virtual void * GetGenericContext()
virtual void SetDisplayId(void *)
Dummy stubs for vtkWindow API.
virtual void StereoMidpoint()
Intermediate method performs operations required between the rendering of the left and right eye.
virtual int * GetScreenSize()
Get the current size of the screen in pixels.
virtual void WindowRemap(void)
Remap the rendering window.
virtual void SetPosition(int a[2])
virtual void SetFullScreen(int)
Turn on/off rendering full screen window size.
virtual void SetNextWindowId(void *)
virtual void * GetGenericDisplayId()
virtual void Initialize(void)
Initialize the rendering window.
std::string GetTrackedDeviceString(vr::IVRSystem *pHmd, vr::TrackedDeviceIndex_t unDevice, vr::TrackedDeviceProperty prop, vr::TrackedPropertyError *peError=NULL)
void MakeCurrent()
Make this windows OpenGL context the current context.
vtkOpenGLVertexBufferObject * DistortionVBO
virtual void SetSize(int, int)
Set the size of the window in pixels.
virtual int GetEventPending()
Check to see if a mouse button has been pressed or mouse wheel activated.
GLuint GetLeftRenderBufferId()
Get the frame buffers used for rendering.
int IsDirect()
Is this render window using hardware acceleration? 0-false, 1-true.
void GetRenderBufferSize(int &width, int &height)
vr::IVRRenderModels * OpenVRRenderModels
create a window for renderers to draw into
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:61
virtual void SetPosition(int, int)
@ height
Definition: vtkX3D.h:254
@ string
Definition: vtkX3D.h:490