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 =========================================================================*/
28 #ifndef vtkOpenGLRenderWindow_h
29 #define vtkOpenGLRenderWindow_h
30 
31 #include "vtkRenderingOpenGLModule.h" // For export macro
32 #include "vtkRenderWindow.h"
33 #include "vtkOpenGL.h" // Needed for GLuint.
34 
35 class vtkIdList;
39 class vtkStdString;
40 
41 class VTKRENDERINGOPENGL_EXPORT vtkOpenGLRenderWindow : public vtkRenderWindow
42 {
43 public:
45  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
46 
48 
51  static void SetGlobalMaximumNumberOfMultiSamples(int val);
52  static int GetGlobalMaximumNumberOfMultiSamples();
54 
58  const char *GetRenderingBackend() VTK_OVERRIDE;
59 
63  void StereoUpdate() VTK_OVERRIDE;
64 
66 
69  unsigned char *GetPixelData(int x,int y,int x2,int y2,int front) VTK_OVERRIDE;
70  int GetPixelData(int x,int y,int x2,int y2, int front,
71  vtkUnsignedCharArray *data) VTK_OVERRIDE;
72  int SetPixelData(int x,int y,int x2,int y2,unsigned char *data,
73  int front) VTK_OVERRIDE;
74  int SetPixelData(int x,int y,int x2,int y2,
75  vtkUnsignedCharArray *data, int front) VTK_OVERRIDE;
77 
79 
82  float *GetRGBAPixelData(int x,int y,int x2,int y2,int front) VTK_OVERRIDE;
83  int GetRGBAPixelData(int x,int y,int x2,int y2, int front,
84  vtkFloatArray* data) VTK_OVERRIDE;
85  int SetRGBAPixelData(int x,int y,int x2,int y2, float *data,
86  int front, int blend=0) VTK_OVERRIDE;
87  int SetRGBAPixelData(int x,int y,int x2,int y2, vtkFloatArray *data,
88  int front, int blend=0) VTK_OVERRIDE;
89  void ReleaseRGBAPixelData(float *data) VTK_OVERRIDE;
90  unsigned char *GetRGBACharPixelData(int x,int y,int x2,int y2,
91  int front) VTK_OVERRIDE;
92  int GetRGBACharPixelData(int x,int y,int x2,int y2, int front,
93  vtkUnsignedCharArray *data) VTK_OVERRIDE;
94  int SetRGBACharPixelData(int x, int y, int x2, int y2,
95  unsigned char *data, int front,
96  int blend=0) VTK_OVERRIDE;
97  int SetRGBACharPixelData(int x,int y,int x2,int y2,
98  vtkUnsignedCharArray *data, int front,
99  int blend=0) VTK_OVERRIDE;
101 
103 
106  float *GetZbufferData( int x1, int y1, int x2, int y2 ) VTK_OVERRIDE;
107  int GetZbufferData( int x1, int y1, int x2, int y2, float* z ) VTK_OVERRIDE;
108  int GetZbufferData( int x1, int y1, int x2, int y2,
109  vtkFloatArray* z ) VTK_OVERRIDE;
110  int SetZbufferData( int x1, int y1, int x2, int y2, float *buffer ) VTK_OVERRIDE;
111  int SetZbufferData( int x1, int y1, int x2, int y2,
112  vtkFloatArray *buffer ) VTK_OVERRIDE;
114 
118  void RegisterTextureResource (GLuint id);
119 
123  int GetDepthBufferSize() VTK_OVERRIDE;
124 
129  int GetColorBufferSizes(int *rgba) VTK_OVERRIDE;
130 
132 
135  void SetSize(int a[2]) VTK_OVERRIDE;
136  void SetSize(int,int) VTK_OVERRIDE;
138 
142  virtual void OpenGLInit();
143 
144  // Initialize the state of OpenGL that VTK wants for this window
145  virtual void OpenGLInitState();
146 
147  // Initialize VTK for rendering in a new OpenGL context
148  virtual void OpenGLInitContext();
149 
157  unsigned int GetBackLeftBuffer();
158 
166  unsigned int GetBackRightBuffer();
167 
175  unsigned int GetFrontLeftBuffer();
176 
184  unsigned int GetFrontRightBuffer();
185 
193  unsigned int GetBackBuffer();
194 
202  unsigned int GetFrontBuffer();
203 
207  virtual vtkMTimeType GetContextCreationTime();
208 
213  vtkOpenGLExtensionManager* GetExtensionManager();
214 
219  vtkOpenGLHardwareSupport* GetHardwareSupport();
220 
225  vtkTextureUnitManager *GetTextureUnitManager();
226 
231  void WaitForCompletion() VTK_OVERRIDE;
232 
234 
242  int SetUseOffScreenBuffers(bool offScreen) VTK_OVERRIDE;
243  bool GetUseOffScreenBuffers() VTK_OVERRIDE;
245 
246 protected:
248  ~vtkOpenGLRenderWindow() VTK_OVERRIDE;
249 
250  long OldMonitorSetting;
251  vtkIdList *TextureResourceIds;
252 
253  int GetPixelData(int x, int y, int x2, int y2, int front, unsigned char* data);
254  int GetRGBAPixelData(int x, int y, int x2, int y2, int front, float* data);
255  int GetRGBACharPixelData(int x, int y, int x2, int y2, int front,
256  unsigned char* data);
257 
267  int CreateHardwareOffScreenWindow(int width, int height);
268 
269  int CreateHardwareOffScreenBuffers(int width, int height, bool bind = false);
270  void BindHardwareOffScreenBuffers();
271 
277  void DestroyHardwareOffScreenWindow();
278 
279  void UnbindHardwareOffScreenBuffers();
280  void DestroyHardwareOffScreenBuffers();
281 
285  int OffScreenUseFrameBuffer;
286 
288 
291  int NumberOfFrameBuffers;
292  unsigned int TextureObjects[4]; // really GLuint
293  unsigned int FrameBufferObject; // really GLuint
294  unsigned int DepthRenderBufferObject; // really GLuint
295  int HardwareBufferSize[2];
296  bool HardwareOffScreenBuffersBind;
298 
302  virtual void CreateAWindow() = 0;
303 
307  virtual void DestroyWindow() = 0;
308 
312  void SetTextureUnitManager(vtkTextureUnitManager *textureUnitManager);
313 
314  unsigned int BackLeftBuffer;
315  unsigned int BackRightBuffer;
316  unsigned int FrontLeftBuffer;
317  unsigned int FrontRightBuffer;
318  unsigned int FrontBuffer;
319  unsigned int BackBuffer;
320 
324  int OwnContext;
325 
326  vtkTimeStamp ContextCreationTime;
327 
328  vtkTextureUnitManager *TextureUnitManager;
329 
330 private:
331  vtkOpenGLRenderWindow(const vtkOpenGLRenderWindow&) VTK_DELETE_FUNCTION;
332  void operator=(const vtkOpenGLRenderWindow&) VTK_DELETE_FUNCTION;
333 
334  void SetExtensionManager(vtkOpenGLExtensionManager*);
335  void SetHardwareSupport(vtkOpenGLHardwareSupport * renderWindow);
336 
337  vtkOpenGLExtensionManager* ExtensionManager;
338  vtkOpenGLHardwareSupport* HardwareSupport;
339 };
340 
341 #endif
OpenGL rendering window.
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:47
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:300
record modification and/or execution time
Definition: vtkTimeStamp.h:35
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:41
a simple class to control print indentation
Definition: vtkIndent.h:39
list of point or cell ids
Definition: vtkIdList.h:36
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.