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 =========================================================================*/
27 #ifndef __vtkOpenGLRenderWindow_h
28 #define __vtkOpenGLRenderWindow_h
29 
30 #include "vtkRenderWindow.h"
31 
32 #include "vtkOpenGL.h" // Needed for GLuint.
33 
34 class vtkIdList;
38 
40 {
41 protected:
43 
44 public:
46  void PrintSelf(ostream& os, vtkIndent indent);
47 
49 
50  static void SetGlobalMaximumNumberOfMultiSamples(int val);
51  static int GetGlobalMaximumNumberOfMultiSamples();
53 
55  virtual void StereoUpdate();
56 
58 
59  virtual unsigned char *GetPixelData(int x,int y,int x2,int y2,int front);
60  virtual int GetPixelData(int x,int y,int x2,int y2, int front,
62  virtual int SetPixelData(int x,int y,int x2,int y2,unsigned char *data,
63  int front);
64  virtual int SetPixelData(int x,int y,int x2,int y2,
65  vtkUnsignedCharArray *data, int front);
67 
69 
70  virtual float *GetRGBAPixelData(int x,int y,int x2,int y2,int front);
71  virtual int GetRGBAPixelData(int x,int y,int x2,int y2, int front,
73  virtual int SetRGBAPixelData(int x,int y,int x2,int y2, float *data,
74  int front, int blend=0);
75  virtual int SetRGBAPixelData(int x,int y,int x2,int y2, vtkFloatArray *data,
76  int front, int blend=0);
77  virtual void ReleaseRGBAPixelData(float *data);
78  virtual unsigned char *GetRGBACharPixelData(int x,int y,int x2,int y2,
79  int front);
80  virtual int GetRGBACharPixelData(int x,int y,int x2,int y2, int front,
82  virtual int SetRGBACharPixelData(int x, int y, int x2, int y2,
83  unsigned char *data, int front,
84  int blend=0);
85  virtual int SetRGBACharPixelData(int x,int y,int x2,int y2,
86  vtkUnsignedCharArray *data, int front,
87  int blend=0);
89 
91 
92  virtual float *GetZbufferData( int x1, int y1, int x2, int y2 );
93  virtual int GetZbufferData( int x1, int y1, int x2, int y2, float* z );
94  virtual int GetZbufferData( int x1, int y1, int x2, int y2,
95  vtkFloatArray* z );
96  virtual int SetZbufferData( int x1, int y1, int x2, int y2, float *buffer );
97  virtual int SetZbufferData( int x1, int y1, int x2, int y2,
98  vtkFloatArray *buffer );
100 
102  void RegisterTextureResource (GLuint id);
103 
105  int GetDepthBufferSize();
106 
109  int GetColorBufferSizes(int *rgba);
110 
112  virtual void OpenGLInit();
113 
114  // Initialize the state of OpenGL that VTK wants for this window
115  virtual void OpenGLInitState();
116 
117  // Initialize VTK for rendering in a new OpenGL context
118  virtual void OpenGLInitContext();
119 
125  unsigned int GetBackLeftBuffer();
126 
132  unsigned int GetBackRightBuffer();
133 
139  unsigned int GetFrontLeftBuffer();
140 
146  unsigned int GetFrontRightBuffer();
147 
153  unsigned int GetBackBuffer();
154 
160  unsigned int GetFrontBuffer();
161 
165  virtual void CheckGraphicError();
166 
168  virtual int HasGraphicError();
169 
171  virtual const char *GetLastGraphicErrorString();
172 
174  virtual unsigned long GetContextCreationTime();
175 
178  vtkOpenGLExtensionManager* GetExtensionManager();
179 
182  vtkOpenGLHardwareSupport* GetHardwareSupport();
183 
184  //BTX
186 
188  vtkTextureUnitManager *GetTextureUnitManager();
189  //ETX
191 
194  virtual void WaitForCompletion();
195 
196 protected:
199 
201 
202  int GetPixelData(int x,int y,int x2,int y2,int front, unsigned char* data);
203  int GetRGBAPixelData(int x,int y,int x2,int y2, int front, float* data);
204  int GetRGBACharPixelData(int x,int y,int x2,int y2, int front,
205  unsigned char* data);
206 
212  int CreateHardwareOffScreenWindow(int width, int height);
213 
217  void DestroyHardwareOffScreenWindow();
218 
221 
223 
225  unsigned int TextureObjects[4]; // really GLuint
226  unsigned int FrameBufferObject; // really GLuint
227  unsigned int DepthRenderBufferObject; // really GLuint
229 
231  virtual void CreateAWindow()=0;
232 
234  virtual void DestroyWindow()=0;
235 
237  void SetTextureUnitManager(vtkTextureUnitManager *textureUnitManager);
238 
239  unsigned int BackLeftBuffer;
240  unsigned int BackRightBuffer;
241  unsigned int FrontLeftBuffer;
242  unsigned int FrontRightBuffer;
243  unsigned int FrontBuffer;
244  unsigned int BackBuffer;
245 
246  // Actual type is GLenum. Last value returned by glGetError().
247  unsigned int LastGraphicError;
248 
250 
252 
253 private:
254  vtkOpenGLRenderWindow(const vtkOpenGLRenderWindow&); // Not implemented.
255  void operator=(const vtkOpenGLRenderWindow&); // Not implemented.
256 
257  void SetExtensionManager(vtkOpenGLExtensionManager*);
258  void SetHardwareSupport(vtkOpenGLHardwareSupport * renderWindow);
259 
260  vtkOpenGLExtensionManager* ExtensionManager;
261  vtkOpenGLHardwareSupport* HardwareSupport;
262 };
263 
264 #endif