VTK
vtkOculusRenderWindow.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 =========================================================================*/
38 #ifndef vtkOculusRenderWindow_h
39 #define vtkOculusRenderWindow_h
40 
41 #include "vtkRenderingOculusModule.h" // For export macro
42 #include "vtkOpenGLRenderWindow.h"
43 
44 // Include the Oculus SDK
45 #include "OVR_CAPI_GL.h"
46 #include <SDL.h> // for ivars
47 #include <vector> // ivars
48 #include "vtkOpenGLHelper.h" // used for ivars
49 #include "vtk_glew.h" // used for methods
50 
51 class vtkOculusModel;
53 class vtkTransform;
54 
55 class VTKRENDERINGOCULUS_EXPORT vtkOculusRenderWindow : public vtkOpenGLRenderWindow
56 {
57 public:
58  static vtkOculusRenderWindow *New();
60  void PrintSelf(ostream& os, vtkIndent indent);
61 
65  virtual void Start(void);
66 
71  virtual void StereoUpdate();
72 
77  virtual void StereoMidpoint();
78 
83  virtual void StereoRenderComplete();
84 
88  void Frame(void);
89 
96  virtual void Initialize(void);
97 
103  virtual void Finalize(void);
104 
108  void MakeCurrent();
109 
113  virtual bool IsCurrent();
114 
118  const char *ReportCapabilities() { return "Oculus System";};
119 
123  int IsDirect() { return 1; };
124 
130  virtual int GetEventPending() { return 0;};
131 
135  void Clean();
136 
140  virtual int *GetScreenSize();
141 
143 
146  virtual void SetSize(int,int);
147  virtual void SetSize(int a[2]) {vtkOpenGLRenderWindow::SetSize(a);};
149 
151 
154  virtual void SetPosition(int,int);
155  virtual void SetPosition(int a[2]) {vtkOpenGLRenderWindow::SetPosition(a);};
157 
158  // implement required virtual functions
159  void SetWindowInfo(char *) {};
160  void SetNextWindowInfo(char *) {};
161  void SetParentInfo(char *) {};
162  virtual void *GetGenericDisplayId() {return (void *)this->ContextId;};
163  virtual void *GetGenericWindowId() {return (void *)this->WindowId;};
164  virtual void *GetGenericParentId() {return (void *)NULL;};
165  virtual void *GetGenericContext() {return (void *)this->ContextId;};
166  virtual void *GetGenericDrawable() {return (void *)this->WindowId;};
167  virtual void SetDisplayId(void *) {};
168  void SetWindowId(void *) {};
169  void SetParentId(void *) {};
170  void HideCursor() {};
171  void ShowCursor() {};
172  virtual void SetFullScreen(int) {};
173  virtual void WindowRemap(void) {};
174  virtual void SetNextWindowId(void *) {};
175 
177 
180  ovrSession GetSession() { return this->Session; };
181  ovrLayerEyeFov GetOVRLayer() { return this->OVRLayer; };
183 
187  void UpdateHMDMatrixPose();
188 
192  virtual int SupportsOpenGL() { return 1; };
193 
195 
199  { return this->LeftEyeDesc.m_nResolveFramebufferId; };
201  { return this->RightEyeDesc.m_nResolveFramebufferId; };
203 
208  void Render();
209 
210  ovrVector3f *GetHMDToEyeViewOffsets() {
211  return this->HMDToEyeViewOffsets; }
212 
213 protected:
216 
222 
223  virtual void CreateAWindow() {};
224  virtual void DestroyWindow() {};
225 
226  SDL_Window *WindowId;
227  SDL_GLContext ContextId;
228  ovrSession Session;
229  ovrHmdDesc HMD;
230  ovrLayerEyeFov OVRLayer;
231  ovrVector3f HMDToEyeViewOffsets[2];
232 
234  {
238  ovrTextureSwapChain TextureSwapChain;
239  };
242  bool CreateFrameBuffer(FramebufferDesc &framebufferDesc );
243 
244  // used in computing the pose
246 
247 private:
248  vtkOculusRenderWindow(const vtkOculusRenderWindow&); // Not implemented.
249  void operator=(const vtkOculusRenderWindow&); // Not implemented.
250 };
251 
252 
253 #endif
OpenGL rendering window.
virtual void SetFullScreen(int)
Turn on/off rendering full screen window size.
virtual void Finalize()=0
Finalize the rendering process.
Oculus rendering window.
GLuint GetLeftResolveBufferId()
Get the frame buffers used for rendering.
static vtkRenderWindow * New()
Construct an instance of vtkRenderWindow with its screen size set to 300x300, borders turned on,...
virtual void * GetGenericDrawable()
Dummy stubs for vtkWindow API.
virtual int * GetScreenSize()=0
Get the current size of the screen in pixels.
virtual void WindowRemap(void)
Remap the rendering window.
void SetParentId(void *)
Dummy stubs for vtkWindow API.
ovrSession GetSession()
Get the system pointer.
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:54
void Render() override
Ask each renderer owned by this RenderWindow to render its image and synchronize this process.
virtual void SetPosition(int a[2])
Set the position of the window.
virtual void * GetGenericDisplayId()
Dummy stubs for vtkWindow API.
void SetParentInfo(char *)
Dummy stubs for vtkWindow API.
virtual void SetDisplayId(void *)
Dummy stubs for vtkWindow API.
virtual void * GetGenericWindowId()
Dummy stubs for vtkWindow API.
virtual bool IsCurrent()=0
Tells if this window is the current graphics context for the calling thread.
ovrVector3f * GetHMDToEyeViewOffsets()
void ShowCursor()
Hide or Show the mouse cursor, it is nice to be able to hide the default cursor if you want VTK to di...
void SetWindowInfo(char *)
Dummy stubs for vtkWindow API.
a simple class to control print indentation
Definition: vtkIndent.h:33
virtual void DestroyWindow()=0
Destroy a not-off-screen window.
void SetNextWindowInfo(char *)
Dummy stubs for vtkWindow API.
virtual void StereoUpdate()
Update the system, if needed, due to stereo rendering.
virtual void Frame()=0
A termination method performed at the end of the rendering process to do things like swapping buffers...
virtual void SetNextWindowId(void *)
Dummy stubs for vtkWindow API.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
virtual void StereoRenderComplete()
Handles work required once both views have been rendered when using stereo rendering.
create a window for renderers to draw into
virtual void * GetGenericContext()
Dummy stubs for vtkWindow API.
virtual int SupportsOpenGL()
Does this render window support OpenGL? 0-false, 1-true.
virtual void SetSize(int a[2])
Set the size of the window in pixels.
void SetSize(int a[2]) override
Set the size of the window in screen coordinates in pixels.
virtual void StereoMidpoint()
Intermediate method performs operations required between the rendering of the left and right eye.
virtual void Start()=0
Initialize the rendering process.
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...
virtual int GetEventPending()
Check to see if a mouse button has been pressed or mouse wheel activated.
virtual void SetPosition(int, int)
Set/Get the position in screen coordinates of the rendering window.
GLuint GetRightResolveBufferId()
Get the frame buffers used for rendering.
ovrLayerEyeFov GetOVRLayer()
Get the system pointer.
int IsDirect()
Is this render window using hardware acceleration? 0-false, 1-true.
const char * ReportCapabilities()
Get report of capabilities for the render window.
virtual void ReleaseGraphicsResources(vtkRenderWindow *)
Free up any graphics resources associated with this window a value of NULL means the context may alre...
virtual void CreateAWindow()
Create a not-off-screen window.
virtual void Initialize(void)
Initialize the rendering window.
void MakeCurrent() override=0
Attempt to make this window the current graphics context for the calling thread.
void SetWindowId(void *)
Dummy stubs for vtkWindow API.
virtual void * GetGenericParentId()
Dummy stubs for vtkWindow API.