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 =========================================================================*/
41 #ifndef vtkOculusRenderWindow_h
42 #define vtkOculusRenderWindow_h
43 
44 #include "vtkRenderingOculusModule.h" // For export macro
45 #include "vtkOpenGLRenderWindow.h"
46 
47 // Include the Oculus SDK
48 #include "OVR_CAPI_GL.h"
49 #include <SDL.h> // for ivars
50 #include <vector> // ivars
51 #include "vtkOpenGLHelper.h" // used for ivars
52 #include "vtk_glew.h" // used for methods
53 
54 class vtkOculusModel;
56 class vtkTransform;
57 
58 class VTKRENDERINGOCULUS_EXPORT vtkOculusRenderWindow : public vtkOpenGLRenderWindow
59 {
60 public:
61  static vtkOculusRenderWindow *New();
63  void PrintSelf(ostream& os, vtkIndent indent);
64 
68  virtual void Start(void);
69 
74  virtual void StereoUpdate();
75 
80  virtual void StereoMidpoint();
81 
86  virtual void StereoRenderComplete();
87 
91  void Frame(void);
92 
99  virtual void Initialize(void);
100 
106  virtual void Finalize(void);
107 
111  void MakeCurrent();
112 
116  virtual bool IsCurrent();
117 
121  const char *ReportCapabilities() { return "Oculus System";};
122 
126  int IsDirect() { return 1; };
127 
133  virtual int GetEventPending() { return 0;};
134 
138  void Clean();
139 
143  virtual int *GetScreenSize();
144 
146 
149  virtual void SetSize(int,int);
150  virtual void SetSize(int a[2]) {vtkOpenGLRenderWindow::SetSize(a);};
152 
154 
157  virtual void SetPosition(int,int);
158  virtual void SetPosition(int a[2]) {vtkOpenGLRenderWindow::SetPosition(a);};
160 
161  // implement required virtual functions
162  void SetWindowInfo(char *) {};
163  void SetNextWindowInfo(char *) {};
164  void SetParentInfo(char *) {};
165  virtual void *GetGenericDisplayId() {return (void *)this->ContextId;};
166  virtual void *GetGenericWindowId() {return (void *)this->WindowId;};
167  virtual void *GetGenericParentId() {return (void *)NULL;};
168  virtual void *GetGenericContext() {return (void *)this->ContextId;};
169  virtual void *GetGenericDrawable() {return (void *)this->WindowId;};
170  virtual void SetDisplayId(void *) {};
171  void SetWindowId(void *) {};
172  void SetParentId(void *) {};
173  void HideCursor() {};
174  void ShowCursor() {};
175  virtual void SetFullScreen(int) {};
176  virtual void WindowRemap(void) {};
177  virtual void SetNextWindowId(void *) {};
178 
180 
183  ovrSession GetSession() { return this->Session; };
184  ovrLayerEyeFov GetOVRLayer() { return this->OVRLayer; };
186 
190  void UpdateHMDMatrixPose();
191 
195  virtual int SupportsOpenGL() { return 1; };
196 
198 
202  { return this->LeftEyeDesc.m_nResolveFramebufferId; };
204  { return this->RightEyeDesc.m_nResolveFramebufferId; };
206 
211  void Render();
212 
213  ovrVector3f *GetHMDToEyeViewOffsets() {
214  return this->HMDToEyeViewOffsets; }
215 
216 protected:
219 
225 
226  virtual void CreateAWindow() {};
227  virtual void DestroyWindow() {};
228 
229  SDL_Window *WindowId;
230  SDL_GLContext ContextId;
231  ovrSession Session;
232  ovrHmdDesc HMD;
233  ovrLayerEyeFov OVRLayer;
234  ovrVector3f HMDToEyeViewOffsets[2];
235 
237  {
241  ovrTextureSwapChain TextureSwapChain;
242  };
245  bool CreateFrameBuffer(FramebufferDesc &framebufferDesc );
246 
247  // used in computing the pose
249 
250 private:
251  vtkOculusRenderWindow(const vtkOculusRenderWindow&); // Not implemented.
252  void operator=(const vtkOculusRenderWindow&); // Not implemented.
253 };
254 
255 
256 #endif
OpenGL rendering window.
virtual void SetFullScreen(int)
Turn on/off rendering full screen window size.
virtual void Finalize()=0
Finalize the rendering process.
void PrintSelf(ostream &os, vtkIndent indent)
Methods invoked by print to print information about the object including superclasses.
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:60
virtual void SetSize(int a[2])
Set the size of the window in screen coordinates in pixels.
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:39
virtual void DestroyWindow()=0
Destroy a not-off-screen window.
virtual void MakeCurrent()=0
Attempt to make this window the current graphics context for the calling thread.
void SetNextWindowInfo(char *)
Dummy stubs for vtkWindow API.
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.
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.
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.
virtual void Render()
Ask each renderer owned by this RenderWindow to render its image and synchronize this process...
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 StereoUpdate()
Update system if needed due to stereo rendering.
virtual void CreateAWindow()
Create a not-off-screen window.
virtual void Initialize(void)
Initialize the rendering window.
void SetWindowId(void *)
Dummy stubs for vtkWindow API.
virtual void * GetGenericParentId()
Dummy stubs for vtkWindow API.