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:
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 
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
a simple class to control print indentation
Definition: vtkIndent.h:40
Oculus rendering window.
virtual void SetPosition(int a[2])
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...
ovrSession GetSession()
Get the system pointer.
virtual void Initialize(void)
Initialize the rendering window.
void Clean()
Clean up device contexts, rendering contexts, etc.
virtual void Finalize(void)
Finalize the rendering window.
virtual void WindowRemap(void)
Remap the rendering window.
virtual void * GetGenericDrawable()
virtual void Start(void)
Begin the rendering process.
ovrVector3f * GetHMDToEyeViewOffsets()
virtual void SetDisplayId(void *)
Dummy stubs for vtkWindow API.
virtual int GetEventPending()
Check to see if a mouse button has been pressed or mouse wheel activated.
GLuint GetLeftResolveBufferId()
Get the frame buffers used for rendering.
int IsDirect()
Is this render window using hardware acceleration? 0-false, 1-true.
virtual bool IsCurrent()
Tells if this window is the current OpenGL context for the calling thread.
virtual void CreateAWindow()
Create a not-off-screen window.
void MakeCurrent()
Make this windows OpenGL context the current context.
virtual int SupportsOpenGL()
Does this render window support OpenGL? 0-false, 1-true.
virtual void StereoUpdate()
Update the system, if needed, due to stereo rendering.
virtual void * GetGenericDisplayId()
virtual void StereoMidpoint()
Intermediate method performs operations required between the rendering of the left and right eye.
virtual void * GetGenericContext()
void Frame(void)
End the rendering process and display the image.
virtual void * GetGenericWindowId()
void Render()
Overridden to not release resources that would interfere with an external application's rendering.
const char * ReportCapabilities()
Get report of capabilities for the render window.
virtual void StereoRenderComplete()
Handles work required once both views have been rendered when using stereo rendering.
virtual void SetFullScreen(int)
Turn on/off rendering full screen window size.
bool CreateFrameBuffer(FramebufferDesc &framebufferDesc)
virtual void DestroyWindow()
Destroy a not-off-screen window.
static vtkOculusRenderWindow * New()
virtual int * GetScreenSize()
Get the current size of the screen in pixels.
void UpdateHMDMatrixPose()
Update the HMD pose.
virtual void SetNextWindowId(void *)
virtual void SetSize(int, int)
Set the size of the window 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 PrintSelf(ostream &os, vtkIndent indent)
Methods invoked by print to print information about the object including superclasses.
virtual void SetSize(int a[2])
Set the size of the window in screen coordinates in pixels.
virtual void SetPosition(int, int)
Set the position of the window.
OpenGL rendering window.
virtual void SetSize(int a[2])
Set the size of the window in screen coordinates in pixels.
create a window for renderers to draw into
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:61
virtual void SetPosition(int, int)