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 #include "vtkType.h" // for ivar
31 
32 class vtkIdList;
36 class vtkShaderProgram;
37 class vtkStdString;
38 class vtkTexture;
39 class vtkTextureObject;
41 
43 {
44 public:
46  void PrintSelf(ostream& os, vtkIndent indent);
47 
50  void Render();
51 
53 
54  static void SetGlobalMaximumNumberOfMultiSamples(int val);
55  static int GetGlobalMaximumNumberOfMultiSamples();
57 
59  virtual void StereoUpdate();
60 
62 
63  virtual unsigned char *GetPixelData(int x,int y,int x2,int y2,int front);
64  virtual int GetPixelData(int x,int y,int x2,int y2, int front,
66  virtual int SetPixelData(int x,int y,int x2,int y2,unsigned char *data,
67  int front);
68  virtual int SetPixelData(int x,int y,int x2,int y2,
69  vtkUnsignedCharArray *data, int front);
71 
73 
74  virtual float *GetRGBAPixelData(int x,int y,int x2,int y2,int front);
75  virtual int GetRGBAPixelData(int x,int y,int x2,int y2, int front,
77  virtual int SetRGBAPixelData(int x,int y,int x2,int y2, float *data,
78  int front, int blend=0);
79  virtual int SetRGBAPixelData(int x,int y,int x2,int y2, vtkFloatArray *data,
80  int front, int blend=0);
81  virtual void ReleaseRGBAPixelData(float *data);
82  virtual unsigned char *GetRGBACharPixelData(int x,int y,int x2,int y2,
83  int front);
84  virtual int GetRGBACharPixelData(int x,int y,int x2,int y2, int front,
86  virtual int SetRGBACharPixelData(int x, int y, int x2, int y2,
87  unsigned char *data, int front,
88  int blend=0);
89  virtual int SetRGBACharPixelData(int x,int y,int x2,int y2,
90  vtkUnsignedCharArray *data, int front,
91  int blend=0);
93 
95 
96  virtual float *GetZbufferData( int x1, int y1, int x2, int y2 );
97  virtual int GetZbufferData( int x1, int y1, int x2, int y2, float* z );
98  virtual int GetZbufferData( int x1, int y1, int x2, int y2,
99  vtkFloatArray* z );
100  virtual int SetZbufferData( int x1, int y1, int x2, int y2, float *buffer );
101  virtual int SetZbufferData( int x1, int y1, int x2, int y2,
102  vtkFloatArray *buffer );
104 
105 
107  void ActivateTexture(vtkTextureObject *);
108 
110  void DeactivateTexture(vtkTextureObject *);
111 
113  int GetTextureUnitForTexture(vtkTextureObject *);
114 
116  int GetDepthBufferSize();
117 
120  int GetColorBufferSizes(int *rgba);
121 
123  virtual void OpenGLInit();
124 
125  // Initialize the state of OpenGL that VTK wants for this window
126  virtual void OpenGLInitState();
127 
128  // Initialize VTK for rendering in a new OpenGL context
129  virtual void OpenGLInitContext();
130 
132 
133  static bool GetContextSupportsOpenGL32();
134  void SetContextSupportsOpenGL32(bool val);
136 
142  unsigned int GetBackLeftBuffer();
143 
149  unsigned int GetBackRightBuffer();
150 
156  unsigned int GetFrontLeftBuffer();
157 
163  unsigned int GetFrontRightBuffer();
164 
170  unsigned int GetBackBuffer();
171 
177  unsigned int GetFrontBuffer();
178 
180  virtual unsigned long GetContextCreationTime();
181 
183 
184  vtkGetObjectMacro(ShaderCache,vtkOpenGLShaderCache);
186 
189  vtkTextureUnitManager *GetTextureUnitManager();
190 
193  virtual void WaitForCompletion();
194 
196 
197  virtual void DrawPixels(int x1, int y1, int x2, int y2,
198  int numComponents, int dataType, void *data);
200 
202 
204  virtual void DrawPixels(
205  int dstXmin, int dstYmin, int dstXmax, int dstYmax,
206  int srcXmin, int srcYmin, int srcXmax, int srcYmax,
207  int srcWidth, int srcHeight, int numComponents, int dataType, void *data);
209 
211 
213  virtual void DrawPixels(
214  int srcWidth, int srcHeight, int numComponents, int dataType, void *data);
216 
218 
219  virtual float GetMaximumHardwareLineWidth() {
220  return this->MaximumHardwareLineWidth; };
222 
224 
228  virtual bool IsPointSpriteBugPresent()
229  {
230  return 0;
231  }
233 
235 
238  int GetDefaultTextureInternalFormat(
239  int vtktype, int numComponents,
240  bool needInteger, bool needFloat);
242 
243 protected:
246 
248 
249  int TextureInternalFormats[VTK_UNICODE_STRING][3][5];
250  void InitializeTextureInternalFormats();
251 
252  long OldMonitorSetting;
253 
254  std::map<const vtkTextureObject *, int> TextureResourceIds;
255 
256  int GetPixelData(int x, int y, int x2, int y2, int front, unsigned char* data);
257  int GetRGBAPixelData(int x, int y, int x2, int y2, int front, float* data);
258  int GetRGBACharPixelData(int x, int y, int x2, int y2, int front,
259  unsigned char* data);
260 
266  int CreateHardwareOffScreenWindow(int width, int height);
267 
271  void DestroyHardwareOffScreenWindow();
272 
274  int OffScreenUseFrameBuffer;
275 
277 
278  int NumberOfFrameBuffers;
279  unsigned int TextureObjects[4]; // really GLuint
280  unsigned int FrameBufferObject; // really GLuint
281  unsigned int DepthRenderBufferObject; // really GLuint
283 
285  virtual void CreateAWindow() = 0;
286 
288  virtual void DestroyWindow() = 0;
289 
292  virtual void ReleaseGraphicsResources(vtkRenderWindow *);
293 
295  void SetTextureUnitManager(vtkTextureUnitManager *textureUnitManager);
296 
297 
299  void SaveGLState();
300 
302  void RestoreGLState();
303 
304  std::map<std::string, int> GLStateIntegers;
305 
306  unsigned int BackLeftBuffer;
307  unsigned int BackRightBuffer;
308  unsigned int FrontLeftBuffer;
309  unsigned int FrontRightBuffer;
310  unsigned int FrontBuffer;
311  unsigned int BackBuffer;
312 
313  #ifndef VTK_LEGACY_REMOVE
314 
315 
316  unsigned int LastGraphicError;
317  #endif
318 
319 
321  int OwnContext;
322 
323  vtkTimeStamp ContextCreationTime;
324 
325  vtkTextureUnitManager *TextureUnitManager;
326 
328 
329  bool Initialized; // ensure glewinit has been called
330 
332 
333 private:
334  vtkOpenGLRenderWindow(const vtkOpenGLRenderWindow&); // Not implemented.
335  void operator=(const vtkOpenGLRenderWindow&); // Not implemented.
336 };
337 
338 #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
#define VTKRENDERINGOPENGL2_EXPORT
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
#define VTK_UNICODE_STRING
Definition: vtkType.h:58
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
virtual bool IsPointSpriteBugPresent()
std::map< std::string, int > GLStateIntegers
The ShaderProgram uses one or more Shader objects.