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 =========================================================================*/
24 #ifndef vtkOpenGLRenderWindow_h
25 #define vtkOpenGLRenderWindow_h
26 
27 #include "vtkRenderingOpenGL2Module.h" // For export macro
28 #include "vtkRenderWindow.h"
29 #include <map> // for ivar
30 
31 #include "vtk_glew.h" // Needed for GLuint.
32 
33 class vtkIdList;
37 class vtkStdString;
38 class vtkTexture;
39 class vtkTextureObject;
40 class vtkShaderProgram;
41 
42 namespace vtkgl
43 {
44 class VertexArrayObject;
45 }
46 
47 class VTKRENDERINGOPENGL2_EXPORT vtkOpenGLRenderWindow : public vtkRenderWindow
48 {
49 public:
51  void PrintSelf(ostream& os, vtkIndent indent);
52 
54 
55  static void SetGlobalMaximumNumberOfMultiSamples(int val);
56  static int GetGlobalMaximumNumberOfMultiSamples();
58 
60  virtual void StereoUpdate();
61 
63 
64  virtual unsigned char *GetPixelData(int x,int y,int x2,int y2,int front);
65  virtual int GetPixelData(int x,int y,int x2,int y2, int front,
67  virtual int SetPixelData(int x,int y,int x2,int y2,unsigned char *data,
68  int front);
69  virtual int SetPixelData(int x,int y,int x2,int y2,
70  vtkUnsignedCharArray *data, int front);
72 
74 
75  virtual float *GetRGBAPixelData(int x,int y,int x2,int y2,int front);
76  virtual int GetRGBAPixelData(int x,int y,int x2,int y2, int front,
78  virtual int SetRGBAPixelData(int x,int y,int x2,int y2, float *data,
79  int front, int blend=0);
80  virtual int SetRGBAPixelData(int x,int y,int x2,int y2, vtkFloatArray *data,
81  int front, int blend=0);
82  virtual void ReleaseRGBAPixelData(float *data);
83  virtual unsigned char *GetRGBACharPixelData(int x,int y,int x2,int y2,
84  int front);
85  virtual int GetRGBACharPixelData(int x,int y,int x2,int y2, int front,
87  virtual int SetRGBACharPixelData(int x, int y, int x2, int y2,
88  unsigned char *data, int front,
89  int blend=0);
90  virtual int SetRGBACharPixelData(int x,int y,int x2,int y2,
91  vtkUnsignedCharArray *data, int front,
92  int blend=0);
94 
96 
97  virtual float *GetZbufferData( int x1, int y1, int x2, int y2 );
98  virtual int GetZbufferData( int x1, int y1, int x2, int y2, float* z );
99  virtual int GetZbufferData( int x1, int y1, int x2, int y2,
100  vtkFloatArray* z );
101  virtual int SetZbufferData( int x1, int y1, int x2, int y2, float *buffer );
102  virtual int SetZbufferData( int x1, int y1, int x2, int y2,
105 
106 
108  void ActivateTexture(vtkTextureObject *);
109 
111  void DeactivateTexture(vtkTextureObject *);
112 
114  int GetTextureUnitForTexture(vtkTextureObject *);
115 
117  int GetDepthBufferSize();
118 
121  int GetColorBufferSizes(int *rgba);
122 
124  virtual void OpenGLInit();
125 
126  // Initialize the state of OpenGL that VTK wants for this window
127  virtual void OpenGLInitState();
128 
129  // Initialize VTK for rendering in a new OpenGL context
130  virtual void OpenGLInitContext();
131 
133 
134  static bool GetContextSupportsOpenGL32();
135  void SetContextSupportsOpenGL32(bool val);
137 
143  unsigned int GetBackLeftBuffer();
144 
150  unsigned int GetBackRightBuffer();
151 
157  unsigned int GetFrontLeftBuffer();
158 
164  unsigned int GetFrontRightBuffer();
165 
171  unsigned int GetBackBuffer();
172 
178  unsigned int GetFrontBuffer();
179 
181 
182  VTK_LEGACY(virtual void CheckGraphicError());
183  VTK_LEGACY(virtual int HasGraphicError());
184  VTK_LEGACY(virtual const char *GetLastGraphicErrorString());
186 
188  virtual unsigned long GetContextCreationTime();
189 
191 
194 
197  vtkTextureUnitManager *GetTextureUnitManager();
198 
201  virtual void WaitForCompletion();
202 
204 
207  static void RenderQuad(
208  float *verts, float *tcoords,
211 
213 
214  virtual void DrawPixels(int x1, int y1, int x2, int y2,
215  int numComponents, int dataType, void *data);
217 
219 
221  virtual void DrawPixels(
222  int dstXmin, int dstYmin, int dstXmax, int dstYmax,
223  int srcXmin, int srcYmin, int srcXmax, int srcYmax,
224  int srcWidth, int srcHeight, int numComponents, int dataType, void *data);
226 
228 
230  virtual void DrawPixels(
231  int srcWidth, int srcHeight, int numComponents, int dataType, void *data);
233 
234 protected:
237 
239 
240  long OldMonitorSetting;
241 
242  std::map<const vtkTextureObject *, int> TextureResourceIds;
243 
244  int GetPixelData(int x, int y, int x2, int y2, int front, unsigned char* data);
245  int GetRGBAPixelData(int x, int y, int x2, int y2, int front, float* data);
246  int GetRGBACharPixelData(int x, int y, int x2, int y2, int front,
247  unsigned char* data);
248 
254  int CreateHardwareOffScreenWindow(int width, int height);
255 
259  void DestroyHardwareOffScreenWindow();
260 
262  int OffScreenUseFrameBuffer;
263 
265 
266  int NumberOfFrameBuffers;
267  unsigned int TextureObjects[4]; // really GLuint
268  unsigned int FrameBufferObject; // really GLuint
269  unsigned int DepthRenderBufferObject; // really GLuint
271 
273  virtual void CreateAWindow() = 0;
274 
276  virtual void DestroyWindow() = 0;
277 
279  virtual void ReleaseGraphicsResources();
280 
282  void SetTextureUnitManager(vtkTextureUnitManager *textureUnitManager);
283 
284  unsigned int BackLeftBuffer;
285  unsigned int BackRightBuffer;
286  unsigned int FrontLeftBuffer;
287  unsigned int FrontRightBuffer;
288  unsigned int FrontBuffer;
289  unsigned int BackBuffer;
290 
291  #ifndef VTK_LEGACY_REMOVE
292 
293 
294  unsigned int LastGraphicError;
295  #endif
296 
297 
299  int OwnContext;
300 
301  vtkTimeStamp ContextCreationTime;
302 
303  vtkTextureUnitManager *TextureUnitManager;
304 
306 
307  bool Initialized; // ensure glewinit has been called
308 
309 private:
310  vtkOpenGLRenderWindow(const vtkOpenGLRenderWindow&); // Not implemented.
311  void operator=(const vtkOpenGLRenderWindow&); // Not implemented.
312 };
313 
314 #endif
GLsizei GLsizei GLenum GLenum const GLvoid * data
Definition: vtkgl.h:11339
OpenGL rendering window.
virtual int HasGraphicError()=0
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
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
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
virtual unsigned char * GetRGBACharPixelData(int x, int y, int x2, int y2, int front)=0
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
virtual void CheckGraphicError()=0
virtual void ReleaseRGBAPixelData(float *data)=0
vtkTextureObject * DrawPixelsTextureObject
list of point or cell ids
Definition: vtkIdList.h:35
GLint GLint GLsizei width
Definition: vtkgl.h:11316
Definition: vtkgl.h:11267
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()
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
virtual float * GetZbufferData(int x, int y, int x2, int y2)=0
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
GLuint GLfloat * val
Definition: vtkgl.h:13789
The ShaderProgram uses one or more Shader objects.
virtual const char * GetLastGraphicErrorString()=0