VTK
vtkOpenGLRenderWindow.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkOpenGLRenderWindow.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
25 #ifndef vtkOpenGLRenderWindow_h
26 #define vtkOpenGLRenderWindow_h
27 
28 #include "vtkRenderingOpenGLModule.h" // For export macro
29 #include "vtkRenderWindow.h"
30 #include "vtkOpenGL.h" // Needed for GLuint.
31 
32 class vtkIdList;
36 class vtkStdString;
37 
38 class VTKRENDERINGOPENGL_EXPORT vtkOpenGLRenderWindow : public vtkRenderWindow
39 {
40 public:
42  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
43 
45 
48  static void SetGlobalMaximumNumberOfMultiSamples(int val);
49  static int GetGlobalMaximumNumberOfMultiSamples();
51 
55  const char *GetRenderingBackend() VTK_OVERRIDE;
56 
60  void StereoUpdate() VTK_OVERRIDE;
61 
63 
66  unsigned char *GetPixelData(int x,int y,int x2,int y2,int front) VTK_OVERRIDE;
67  int GetPixelData(int x,int y,int x2,int y2, int front,
68  vtkUnsignedCharArray *data) VTK_OVERRIDE;
69  int SetPixelData(int x,int y,int x2,int y2,unsigned char *data,
70  int front) VTK_OVERRIDE;
71  int SetPixelData(int x,int y,int x2,int y2,
72  vtkUnsignedCharArray *data, int front) VTK_OVERRIDE;
74 
76 
79  float *GetRGBAPixelData(int x,int y,int x2,int y2,int front) VTK_OVERRIDE;
80  int GetRGBAPixelData(int x,int y,int x2,int y2, int front,
81  vtkFloatArray* data) VTK_OVERRIDE;
82  int SetRGBAPixelData(int x,int y,int x2,int y2, float *data,
83  int front, int blend=0) VTK_OVERRIDE;
84  int SetRGBAPixelData(int x,int y,int x2,int y2, vtkFloatArray *data,
85  int front, int blend=0) VTK_OVERRIDE;
86  void ReleaseRGBAPixelData(float *data) VTK_OVERRIDE;
87  unsigned char *GetRGBACharPixelData(int x,int y,int x2,int y2,
88  int front) VTK_OVERRIDE;
89  int GetRGBACharPixelData(int x,int y,int x2,int y2, int front,
90  vtkUnsignedCharArray *data) VTK_OVERRIDE;
91  int SetRGBACharPixelData(int x, int y, int x2, int y2,
92  unsigned char *data, int front,
93  int blend=0) VTK_OVERRIDE;
94  int SetRGBACharPixelData(int x,int y,int x2,int y2,
95  vtkUnsignedCharArray *data, int front,
96  int blend=0) VTK_OVERRIDE;
98 
100 
103  float *GetZbufferData( int x1, int y1, int x2, int y2 ) VTK_OVERRIDE;
104  int GetZbufferData( int x1, int y1, int x2, int y2, float* z ) VTK_OVERRIDE;
105  int GetZbufferData( int x1, int y1, int x2, int y2,
106  vtkFloatArray* z ) VTK_OVERRIDE;
107  int SetZbufferData( int x1, int y1, int x2, int y2, float *buffer ) VTK_OVERRIDE;
108  int SetZbufferData( int x1, int y1, int x2, int y2,
109  vtkFloatArray *buffer ) VTK_OVERRIDE;
111 
115  void RegisterTextureResource (GLuint id);
116 
120  int GetDepthBufferSize() VTK_OVERRIDE;
121 
126  int GetColorBufferSizes(int *rgba) VTK_OVERRIDE;
127 
129 
132  void SetSize(int a[2]) VTK_OVERRIDE;
133  void SetSize(int,int) VTK_OVERRIDE;
135 
139  virtual void OpenGLInit();
140 
141  // Initialize the state of OpenGL that VTK wants for this window
142  virtual void OpenGLInitState();
143 
144  // Initialize VTK for rendering in a new OpenGL context
145  virtual void OpenGLInitContext();
146 
154  unsigned int GetBackLeftBuffer();
155 
163  unsigned int GetBackRightBuffer();
164 
172  unsigned int GetFrontLeftBuffer();
173 
181  unsigned int GetFrontRightBuffer();
182 
190  unsigned int GetBackBuffer();
191 
199  unsigned int GetFrontBuffer();
200 
204  virtual vtkMTimeType GetContextCreationTime();
205 
210  vtkOpenGLExtensionManager* GetExtensionManager();
211 
216  vtkOpenGLHardwareSupport* GetHardwareSupport();
217 
222  vtkTextureUnitManager *GetTextureUnitManager();
223 
228  void WaitForCompletion() VTK_OVERRIDE;
229 
231 
239  int SetUseOffScreenBuffers(bool offScreen) VTK_OVERRIDE;
240  bool GetUseOffScreenBuffers() VTK_OVERRIDE;
242 
243 protected:
245  ~vtkOpenGLRenderWindow() VTK_OVERRIDE;
246 
247  long OldMonitorSetting;
248  vtkIdList *TextureResourceIds;
249 
250  int GetPixelData(int x, int y, int x2, int y2, int front, unsigned char* data);
251  int GetRGBAPixelData(int x, int y, int x2, int y2, int front, float* data);
252  int GetRGBACharPixelData(int x, int y, int x2, int y2, int front,
253  unsigned char* data);
254 
264  int CreateHardwareOffScreenWindow(int width, int height);
265 
266  int CreateHardwareOffScreenBuffers(int width, int height, bool bind = false);
267  void BindHardwareOffScreenBuffers();
268 
274  void DestroyHardwareOffScreenWindow();
275 
276  void UnbindHardwareOffScreenBuffers();
277  void DestroyHardwareOffScreenBuffers();
278 
282  int OffScreenUseFrameBuffer;
283 
285 
288  int NumberOfFrameBuffers;
289  unsigned int TextureObjects[4]; // really GLuint
290  unsigned int FrameBufferObject; // really GLuint
291  unsigned int DepthRenderBufferObject; // really GLuint
292  int HardwareBufferSize[2];
293  bool HardwareOffScreenBuffersBind;
295 
299  virtual void CreateAWindow() = 0;
300 
304  virtual void DestroyWindow() = 0;
305 
309  void SetTextureUnitManager(vtkTextureUnitManager *textureUnitManager);
310 
311  unsigned int BackLeftBuffer;
312  unsigned int BackRightBuffer;
313  unsigned int FrontLeftBuffer;
314  unsigned int FrontRightBuffer;
315  unsigned int FrontBuffer;
316  unsigned int BackBuffer;
317 
321  int OwnContext;
322 
323  vtkTimeStamp ContextCreationTime;
324 
325  vtkTextureUnitManager *TextureUnitManager;
326 
327 private:
328  vtkOpenGLRenderWindow(const vtkOpenGLRenderWindow&) VTK_DELETE_FUNCTION;
329  void operator=(const vtkOpenGLRenderWindow&) VTK_DELETE_FUNCTION;
330 
331  void SetExtensionManager(vtkOpenGLExtensionManager*);
332  void SetHardwareSupport(vtkOpenGLHardwareSupport * renderWindow);
333 
334  vtkOpenGLExtensionManager* ExtensionManager;
335  vtkOpenGLHardwareSupport* HardwareSupport;
336 };
337 
338 #endif
OpenGL rendering window.
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:41
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:300
record modification and/or execution time
Definition: vtkTimeStamp.h:32
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:35
a simple class to control print indentation
Definition: vtkIndent.h:33
list of point or cell ids
Definition: vtkIdList.h:30
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
Interface class for querying and using OpenGL extensions.
dynamic, self-adjusting array of unsigned char
allocate/free texture units.
create a window for renderers to draw into
OpenGL rendering window.
virtual const char * GetRenderingBackend()
What rendering backend has the user requested.