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 #include "vtk_glew.h" // Needed for GLuint.
35 
36 class vtkIdList;
40 class vtkStdString;
41 class vtkTexture;
42 class vtkTextureObject;
43 class vtkShaderProgram;
44 
45 namespace vtkgl
46 {
47 class VertexArrayObject;
48 }
49 
50 class VTKRENDERINGOPENGL2_EXPORT vtkOpenGLRenderWindow : public vtkRenderWindow
51 {
52 public:
54  void PrintSelf(ostream& os, vtkIndent indent);
55 
57 
58  static void SetGlobalMaximumNumberOfMultiSamples(int val);
59  static int GetGlobalMaximumNumberOfMultiSamples();
61 
63  virtual void StereoUpdate();
64 
66 
67  virtual unsigned char *GetPixelData(int x,int y,int x2,int y2,int front);
68  virtual int GetPixelData(int x,int y,int x2,int y2, int front,
70  virtual int SetPixelData(int x,int y,int x2,int y2,unsigned char *data,
71  int front);
72  virtual int SetPixelData(int x,int y,int x2,int y2,
73  vtkUnsignedCharArray *data, int front);
75 
77 
78  virtual float *GetRGBAPixelData(int x,int y,int x2,int y2,int front);
79  virtual int GetRGBAPixelData(int x,int y,int x2,int y2, int front,
81  virtual int SetRGBAPixelData(int x,int y,int x2,int y2, float *data,
82  int front, int blend=0);
83  virtual int SetRGBAPixelData(int x,int y,int x2,int y2, vtkFloatArray *data,
84  int front, int blend=0);
85  virtual void ReleaseRGBAPixelData(float *data);
86  virtual unsigned char *GetRGBACharPixelData(int x,int y,int x2,int y2,
87  int front);
88  virtual int GetRGBACharPixelData(int x,int y,int x2,int y2, int front,
90  virtual int SetRGBACharPixelData(int x, int y, int x2, int y2,
91  unsigned char *data, int front,
92  int blend=0);
93  virtual int SetRGBACharPixelData(int x,int y,int x2,int y2,
94  vtkUnsignedCharArray *data, int front,
95  int blend=0);
97 
99 
100  virtual float *GetZbufferData( int x1, int y1, int x2, int y2 );
101  virtual int GetZbufferData( int x1, int y1, int x2, int y2, float* z );
102  virtual int GetZbufferData( int x1, int y1, int x2, int y2,
103  vtkFloatArray* z );
104  virtual int SetZbufferData( int x1, int y1, int x2, int y2, float *buffer );
105  virtual int SetZbufferData( int x1, int y1, int x2, int y2,
108 
109 
111  void ActivateTexture(vtkTextureObject *);
112 
114  void DeactivateTexture(vtkTextureObject *);
115 
117  int GetTextureUnitForTexture(vtkTextureObject *);
118 
120  int GetDepthBufferSize();
121 
124  int GetColorBufferSizes(int *rgba);
125 
127  virtual void OpenGLInit();
128 
129  // Initialize the state of OpenGL that VTK wants for this window
130  virtual void OpenGLInitState();
131 
132  // Initialize VTK for rendering in a new OpenGL context
133  virtual void OpenGLInitContext();
134 
136 
137  static bool GetContextSupportsOpenGL32();
138  void SetContextSupportsOpenGL32(bool val);
140 
146  unsigned int GetBackLeftBuffer();
147 
153  unsigned int GetBackRightBuffer();
154 
160  unsigned int GetFrontLeftBuffer();
161 
167  unsigned int GetFrontRightBuffer();
168 
174  unsigned int GetBackBuffer();
175 
181  unsigned int GetFrontBuffer();
182 
184 
185  VTK_LEGACY(virtual void CheckGraphicError());
186  VTK_LEGACY(virtual int HasGraphicError());
187  VTK_LEGACY(virtual const char *GetLastGraphicErrorString());
189 
191  virtual unsigned long GetContextCreationTime();
192 
194 
197 
200  vtkTextureUnitManager *GetTextureUnitManager();
201 
204  virtual void WaitForCompletion();
205 
207 
210  static void RenderQuad(
211  float *verts, float *tcoords,
214 
216 
217  virtual void DrawPixels(int x1, int y1, int x2, int y2,
218  int numComponents, int dataType, void *data);
220 
222 
224  virtual void DrawPixels(
225  int dstXmin, int dstYmin, int dstXmax, int dstYmax,
226  int srcXmin, int srcYmin, int srcXmax, int srcYmax,
227  int srcWidth, int srcHeight, int numComponents, int dataType, void *data);
229 
231 
233  virtual void DrawPixels(
234  int srcWidth, int srcHeight, int numComponents, int dataType, void *data);
236 
237 protected:
240 
242 
243  long OldMonitorSetting;
244 
245  std::map<const vtkTextureObject *, int> TextureResourceIds;
246 
247  int GetPixelData(int x, int y, int x2, int y2, int front, unsigned char* data);
248  int GetRGBAPixelData(int x, int y, int x2, int y2, int front, float* data);
249  int GetRGBACharPixelData(int x, int y, int x2, int y2, int front,
250  unsigned char* data);
251 
257  int CreateHardwareOffScreenWindow(int width, int height);
258 
262  void DestroyHardwareOffScreenWindow();
263 
265  int OffScreenUseFrameBuffer;
266 
268 
269  int NumberOfFrameBuffers;
270  unsigned int TextureObjects[4]; // really GLuint
271  unsigned int FrameBufferObject; // really GLuint
272  unsigned int DepthRenderBufferObject; // really GLuint
274 
276  virtual void CreateAWindow() = 0;
277 
279  virtual void DestroyWindow() = 0;
280 
282  virtual void ReleaseGraphicsResources();
283 
285  void SetTextureUnitManager(vtkTextureUnitManager *textureUnitManager);
286 
287  unsigned int BackLeftBuffer;
288  unsigned int BackRightBuffer;
289  unsigned int FrontLeftBuffer;
290  unsigned int FrontRightBuffer;
291  unsigned int FrontBuffer;
292  unsigned int BackBuffer;
293 
294  #ifndef VTK_LEGACY_REMOVE
295 
296 
297  unsigned int LastGraphicError;
298  #endif
299 
300 
302  int OwnContext;
303 
304  vtkTimeStamp ContextCreationTime;
305 
306  vtkTextureUnitManager *TextureUnitManager;
307 
309 
310  bool Initialized; // ensure glewinit has been called
311 
312 private:
313  vtkOpenGLRenderWindow(const vtkOpenGLRenderWindow&); // Not implemented.
314  void operator=(const vtkOpenGLRenderWindow&); // Not implemented.
315 };
316 
317 #endif
GLsizei GLsizei GLenum GLenum const GLvoid * data
Definition: vtkgl.h:11339
OpenGL rendering window.
VTKRENDERINGOPENGL_EXPORT PFNGLXDESTROYWINDOWPROC DestroyWindow
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:46
GLuint buffer
Definition: vtkgl.h:11839
manage Shader Programs within a context
record modification and/or execution time
Definition: vtkTimeStamp.h:34
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:45
GLint GLint GLint GLint GLint GLint y
Definition: vtkgl.h:11318
#define vtkTypeMacro(thisClass, superclass)
Definition: vtkSetGet.h:632
GLint GLint GLsizei GLsizei height
Definition: vtkgl.h:11316
GLdouble GLdouble z
Definition: vtkgl.h:11754
GLint GLint GLint GLint GLint x
Definition: vtkgl.h:11318
std::map< const vtkTextureObject *, int > TextureResourceIds
a simple class to control print indentation
Definition: vtkIndent.h:38
vtkTextureObject * DrawPixelsTextureObject
list of point or cell ids
Definition: vtkIdList.h:35
GLint GLint GLsizei width
Definition: vtkgl.h:11316
Definition: vtkgl.h:11267
handles properties associated with a texture map
Definition: vtkTexture.h:69
The VertexArrayObject class uses, or emulates, vertex array objects.
#define vtkGetObjectMacro(name, type)
Definition: vtkSetGet.h:222
dynamic, self-adjusting array of unsigned char
#define VTK_LEGACY(method)
Definition: vtkSetGet.h:800
allocate/free texture units.
vtkOpenGLShaderCache * ShaderCache
abstracts an OpenGL texture object.
create a window for renderers to draw into
OpenGL rendering window.
GLuint program
Definition: vtkgl.h:13011
GLuint GLfloat * val
Definition: vtkgl.h:13789
The ShaderProgram uses one or more Shader objects.