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 "vtkRenderingOpenGL2Module.h" // For export macro
31 #include "vtkRenderWindow.h"
32 #include <map> // for ivar
33 
34 class vtkIdList;
38 class vtkShaderProgram;
39 class vtkStdString;
40 class vtkTexture;
41 class vtkTextureObject;
43 
44 class VTKRENDERINGOPENGL2_EXPORT vtkOpenGLRenderWindow : public vtkRenderWindow
45 {
46 public:
48  void PrintSelf(ostream& os, vtkIndent indent);
49 
52  void Render();
53 
55 
56  static void SetGlobalMaximumNumberOfMultiSamples(int val);
57  static int GetGlobalMaximumNumberOfMultiSamples();
59 
61  virtual void StereoUpdate();
62 
64 
65  virtual unsigned char *GetPixelData(int x,int y,int x2,int y2,int front);
66  virtual int GetPixelData(int x,int y,int x2,int y2, int front,
68  virtual int SetPixelData(int x,int y,int x2,int y2,unsigned char *data,
69  int front);
70  virtual int SetPixelData(int x,int y,int x2,int y2,
71  vtkUnsignedCharArray *data, int front);
73 
75 
76  virtual float *GetRGBAPixelData(int x,int y,int x2,int y2,int front);
77  virtual int GetRGBAPixelData(int x,int y,int x2,int y2, int front,
79  virtual int SetRGBAPixelData(int x,int y,int x2,int y2, float *data,
80  int front, int blend=0);
81  virtual int SetRGBAPixelData(int x,int y,int x2,int y2, vtkFloatArray *data,
82  int front, int blend=0);
83  virtual void ReleaseRGBAPixelData(float *data);
84  virtual unsigned char *GetRGBACharPixelData(int x,int y,int x2,int y2,
85  int front);
86  virtual int GetRGBACharPixelData(int x,int y,int x2,int y2, int front,
88  virtual int SetRGBACharPixelData(int x, int y, int x2, int y2,
89  unsigned char *data, int front,
90  int blend=0);
91  virtual int SetRGBACharPixelData(int x,int y,int x2,int y2,
92  vtkUnsignedCharArray *data, int front,
93  int blend=0);
95 
97 
98  virtual float *GetZbufferData( int x1, int y1, int x2, int y2 );
99  virtual int GetZbufferData( int x1, int y1, int x2, int y2, float* z );
100  virtual int GetZbufferData( int x1, int y1, int x2, int y2,
101  vtkFloatArray* z );
102  virtual int SetZbufferData( int x1, int y1, int x2, int y2, float *buffer );
103  virtual int SetZbufferData( int x1, int y1, int x2, int y2,
104  vtkFloatArray *buffer );
106 
107 
109  void ActivateTexture(vtkTextureObject *);
110 
112  void DeactivateTexture(vtkTextureObject *);
113 
115  int GetTextureUnitForTexture(vtkTextureObject *);
116 
118  int GetDepthBufferSize();
119 
122  int GetColorBufferSizes(int *rgba);
123 
125  virtual void OpenGLInit();
126 
127  // Initialize the state of OpenGL that VTK wants for this window
128  virtual void OpenGLInitState();
129 
130  // Initialize VTK for rendering in a new OpenGL context
131  virtual void OpenGLInitContext();
132 
134 
135  static bool GetContextSupportsOpenGL32();
136  void SetContextSupportsOpenGL32(bool val);
138 
144  unsigned int GetBackLeftBuffer();
145 
151  unsigned int GetBackRightBuffer();
152 
158  unsigned int GetFrontLeftBuffer();
159 
165  unsigned int GetFrontRightBuffer();
166 
172  unsigned int GetBackBuffer();
173 
179  unsigned int GetFrontBuffer();
180 
182 
183  VTK_LEGACY(virtual void CheckGraphicError());
184  VTK_LEGACY(virtual int HasGraphicError());
185  VTK_LEGACY(virtual const char *GetLastGraphicErrorString());
187 
189  virtual unsigned long GetContextCreationTime();
190 
192 
193  vtkGetObjectMacro(ShaderCache,vtkOpenGLShaderCache);
195 
198  vtkTextureUnitManager *GetTextureUnitManager();
199 
202  virtual void WaitForCompletion();
203 
205 
206  virtual void DrawPixels(int x1, int y1, int x2, int y2,
207  int numComponents, int dataType, void *data);
209 
211 
213  virtual void DrawPixels(
214  int dstXmin, int dstYmin, int dstXmax, int dstYmax,
215  int srcXmin, int srcYmin, int srcXmax, int srcYmax,
216  int srcWidth, int srcHeight, int numComponents, int dataType, void *data);
218 
220 
222  virtual void DrawPixels(
223  int srcWidth, int srcHeight, int numComponents, int dataType, void *data);
225 
227 
228  virtual float GetMaximumHardwareLineWidth() {
229  return this->MaximumHardwareLineWidth; };
231 
232 protected:
235 
237 
238  long OldMonitorSetting;
239 
240  std::map<const vtkTextureObject *, int> TextureResourceIds;
241 
242  int GetPixelData(int x, int y, int x2, int y2, int front, unsigned char* data);
243  int GetRGBAPixelData(int x, int y, int x2, int y2, int front, float* data);
244  int GetRGBACharPixelData(int x, int y, int x2, int y2, int front,
245  unsigned char* data);
246 
252  int CreateHardwareOffScreenWindow(int width, int height);
253 
257  void DestroyHardwareOffScreenWindow();
258 
260  int OffScreenUseFrameBuffer;
261 
263 
264  int NumberOfFrameBuffers;
265  unsigned int TextureObjects[4]; // really GLuint
266  unsigned int FrameBufferObject; // really GLuint
267  unsigned int DepthRenderBufferObject; // really GLuint
269 
271  virtual void CreateAWindow() = 0;
272 
274  virtual void DestroyWindow() = 0;
275 
277  virtual void ReleaseGraphicsResources();
278 
280  void SetTextureUnitManager(vtkTextureUnitManager *textureUnitManager);
281 
282 
284  void SaveGLState();
285 
287  void RestoreGLState();
288 
289  std::map<std::string, int> GLStateIntegers;
290 
291  unsigned int BackLeftBuffer;
292  unsigned int BackRightBuffer;
293  unsigned int FrontLeftBuffer;
294  unsigned int FrontRightBuffer;
295  unsigned int FrontBuffer;
296  unsigned int BackBuffer;
297 
298  #ifndef VTK_LEGACY_REMOVE
299 
300 
301  unsigned int LastGraphicError;
302  #endif
303 
304 
306  int OwnContext;
307 
308  vtkTimeStamp ContextCreationTime;
309 
310  vtkTextureUnitManager *TextureUnitManager;
311 
313 
314  bool Initialized; // ensure glewinit has been called
315 
317 
318 private:
319  vtkOpenGLRenderWindow(const vtkOpenGLRenderWindow&); // Not implemented.
320  void operator=(const vtkOpenGLRenderWindow&); // Not implemented.
321 };
322 
323 #endif
OpenGL rendering window.
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:46
manage Shader Programs within a context
virtual unsigned char * GetPixelData(int x, int y, int x2, int y2, int front)=0
record modification and/or execution time
Definition: vtkTimeStamp.h:34
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:45
virtual int GetColorBufferSizes(int *rgba)=0
virtual int SetRGBAPixelData(int x, int y, int x2, int y2, float *, int front, int blend=0)=0
virtual unsigned char * GetRGBACharPixelData(int x, int y, int x2, int y2, int front)=0
std::map< const vtkTextureObject *, int > TextureResourceIds
a simple class to control print indentation
Definition: vtkIndent.h:38
The VertexArrayObject class uses, or emulates, vertex array objects.
virtual void ReleaseRGBAPixelData(float *data)=0
vtkTextureObject * DrawPixelsTextureObject
list of point or cell ids
Definition: vtkIdList.h:35
virtual int GetDepthBufferSize()=0
void PrintSelf(ostream &os, vtkIndent indent)
virtual int SetZbufferData(int x, int y, int x2, int y2, float *z)=0
virtual float * GetRGBAPixelData(int x, int y, int x2, int y2, int front)=0
handles properties associated with a texture map
Definition: vtkTexture.h:69
virtual void StereoUpdate()
dynamic, self-adjusting array of unsigned char
allocate/free texture units.
vtkOpenGLShaderCache * ShaderCache
abstracts an OpenGL texture object.
create a window for renderers to draw into
OpenGL rendering window.
virtual float GetMaximumHardwareLineWidth()
virtual float * GetZbufferData(int x, int y, int x2, int y2)=0
virtual void Render()
virtual int SetPixelData(int x, int y, int x2, int y2, unsigned char *data, int front)=0
virtual int SetRGBACharPixelData(int x, int y, int x2, int y2, unsigned char *data, int front, int blend=0)=0
virtual void WaitForCompletion()=0
std::map< std::string, int > GLStateIntegers
The ShaderProgram uses one or more Shader objects.