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 class vtkIdList;
35 class vtkShaderProgram;
36 class vtkStdString;
37 class vtkTexture;
38 class vtkTextureObject;
40 
41 class VTKRENDERINGOPENGL2_EXPORT vtkOpenGLRenderWindow : public vtkRenderWindow
42 {
43 public:
45  void PrintSelf(ostream& os, vtkIndent indent);
46 
49  void Render();
50 
52 
53  static void SetGlobalMaximumNumberOfMultiSamples(int val);
54  static int GetGlobalMaximumNumberOfMultiSamples();
56 
58  virtual void StereoUpdate();
59 
61 
62  virtual unsigned char *GetPixelData(int x,int y,int x2,int y2,int front);
63  virtual int GetPixelData(int x,int y,int x2,int y2, int front,
65  virtual int SetPixelData(int x,int y,int x2,int y2,unsigned char *data,
66  int front);
67  virtual int SetPixelData(int x,int y,int x2,int y2,
68  vtkUnsignedCharArray *data, int front);
70 
72 
73  virtual float *GetRGBAPixelData(int x,int y,int x2,int y2,int front);
74  virtual int GetRGBAPixelData(int x,int y,int x2,int y2, int front,
76  virtual int SetRGBAPixelData(int x,int y,int x2,int y2, float *data,
77  int front, int blend=0);
78  virtual int SetRGBAPixelData(int x,int y,int x2,int y2, vtkFloatArray *data,
79  int front, int blend=0);
80  virtual void ReleaseRGBAPixelData(float *data);
81  virtual unsigned char *GetRGBACharPixelData(int x,int y,int x2,int y2,
82  int front);
83  virtual int GetRGBACharPixelData(int x,int y,int x2,int y2, int front,
85  virtual int SetRGBACharPixelData(int x, int y, int x2, int y2,
86  unsigned char *data, int front,
87  int blend=0);
88  virtual int SetRGBACharPixelData(int x,int y,int x2,int y2,
89  vtkUnsignedCharArray *data, int front,
90  int blend=0);
92 
94 
95  virtual float *GetZbufferData( int x1, int y1, int x2, int y2 );
96  virtual int GetZbufferData( int x1, int y1, int x2, int y2, float* z );
97  virtual int GetZbufferData( int x1, int y1, int x2, int y2,
98  vtkFloatArray* z );
99  virtual int SetZbufferData( int x1, int y1, int x2, int y2, float *buffer );
100  virtual int SetZbufferData( int x1, int y1, int x2, int y2,
103 
104 
106  void ActivateTexture(vtkTextureObject *);
107 
109  void DeactivateTexture(vtkTextureObject *);
110 
112  int GetTextureUnitForTexture(vtkTextureObject *);
113 
115  int GetDepthBufferSize();
116 
119  int GetColorBufferSizes(int *rgba);
120 
122  virtual void OpenGLInit();
123 
124  // Initialize the state of OpenGL that VTK wants for this window
125  virtual void OpenGLInitState();
126 
127  // Initialize VTK for rendering in a new OpenGL context
128  virtual void OpenGLInitContext();
129 
131 
132  static bool GetContextSupportsOpenGL32();
133  void SetContextSupportsOpenGL32(bool val);
135 
141  unsigned int GetBackLeftBuffer();
142 
148  unsigned int GetBackRightBuffer();
149 
155  unsigned int GetFrontLeftBuffer();
156 
162  unsigned int GetFrontRightBuffer();
163 
169  unsigned int GetBackBuffer();
170 
176  unsigned int GetFrontBuffer();
177 
179 
180  VTK_LEGACY(virtual void CheckGraphicError());
181  VTK_LEGACY(virtual int HasGraphicError());
182  VTK_LEGACY(virtual const char *GetLastGraphicErrorString());
184 
186  virtual unsigned long GetContextCreationTime();
187 
189 
192 
195  vtkTextureUnitManager *GetTextureUnitManager();
196 
199  virtual void WaitForCompletion();
200 
202 
203  virtual void DrawPixels(int x1, int y1, int x2, int y2,
204  int numComponents, int dataType, void *data);
206 
208 
210  virtual void DrawPixels(
211  int dstXmin, int dstYmin, int dstXmax, int dstYmax,
212  int srcXmin, int srcYmin, int srcXmax, int srcYmax,
213  int srcWidth, int srcHeight, int numComponents, int dataType, void *data);
215 
217 
219  virtual void DrawPixels(
220  int srcWidth, int srcHeight, int numComponents, int dataType, void *data);
222 
224 
225  virtual float GetMaximumHardwareLineWidth() {
226  return this->MaximumHardwareLineWidth; };
228 
229 protected:
232 
234 
235  long OldMonitorSetting;
236 
237  std::map<const vtkTextureObject *, int> TextureResourceIds;
238 
239  int GetPixelData(int x, int y, int x2, int y2, int front, unsigned char* data);
240  int GetRGBAPixelData(int x, int y, int x2, int y2, int front, float* data);
241  int GetRGBACharPixelData(int x, int y, int x2, int y2, int front,
242  unsigned char* data);
243 
249  int CreateHardwareOffScreenWindow(int width, int height);
250 
254  void DestroyHardwareOffScreenWindow();
255 
257  int OffScreenUseFrameBuffer;
258 
260 
261  int NumberOfFrameBuffers;
262  unsigned int TextureObjects[4]; // really GLuint
263  unsigned int FrameBufferObject; // really GLuint
264  unsigned int DepthRenderBufferObject; // really GLuint
266 
268  virtual void CreateAWindow() = 0;
269 
271  virtual void DestroyWindow() = 0;
272 
274  virtual void ReleaseGraphicsResources();
275 
277  void SetTextureUnitManager(vtkTextureUnitManager *textureUnitManager);
278 
279 
281  void SaveGLState();
282 
284  void RestoreGLState();
285 
286  std::map<std::string, int> GLStateIntegers;
287 
288  unsigned int BackLeftBuffer;
289  unsigned int BackRightBuffer;
290  unsigned int FrontLeftBuffer;
291  unsigned int FrontRightBuffer;
292  unsigned int FrontBuffer;
293  unsigned int BackBuffer;
294 
295  #ifndef VTK_LEGACY_REMOVE
296 
297 
298  unsigned int LastGraphicError;
299  #endif
300 
301 
303  int OwnContext;
304 
305  vtkTimeStamp ContextCreationTime;
306 
307  vtkTextureUnitManager *TextureUnitManager;
308 
310 
311  bool Initialized; // ensure glewinit has been called
312 
314 
315 private:
316  vtkOpenGLRenderWindow(const vtkOpenGLRenderWindow&); // Not implemented.
317  void operator=(const vtkOpenGLRenderWindow&); // Not implemented.
318 };
319 
320 #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
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:642
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
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
GLint GLint GLsizei width
Definition: vtkgl.h:11316
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()
#define vtkGetObjectMacro(name, type)
Definition: vtkSetGet.h:232
dynamic, self-adjusting array of unsigned char
#define VTK_LEGACY(method)
Definition: vtkSetGet.h:801
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
GLuint GLfloat * val
Definition: vtkgl.h:13789
The ShaderProgram uses one or more Shader objects.