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 
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 
107 
110 
113 
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 
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 
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 
250 
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 
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
vtkgl::z
GLdouble GLdouble z
Definition: vtkgl.h:11754
vtkOpenGLRenderWindow::SetPixelData
virtual int SetPixelData(int x, int y, int x2, int y2, unsigned char *data, int front)
vtkOpenGLRenderWindow::OpenGLInit
virtual void OpenGLInit()
vtkgl::data
GLsizei GLsizei GLenum GLenum const GLvoid * data
Definition: vtkgl.h:11339
vtkGetObjectMacro
#define vtkGetObjectMacro(name, type)
Definition: vtkSetGet.h:232
vtkOpenGLRenderWindow::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent)
vtkOpenGLRenderWindow::GetMaximumHardwareLineWidth
virtual float GetMaximumHardwareLineWidth()
Definition: vtkOpenGLRenderWindow.h:225
vtkOpenGLRenderWindow::SetZbufferData
virtual int SetZbufferData(int x1, int y1, int x2, int y2, float *buffer)
vtkOpenGLRenderWindow::ActivateTexture
void ActivateTexture(vtkTextureObject *)
vtkOpenGLRenderWindow::DrawPixels
virtual void DrawPixels(int x1, int y1, int x2, int y2, int numComponents, int dataType, void *data)
vtkOpenGLRenderWindow::GetZbufferData
virtual int GetZbufferData(int x1, int y1, int x2, int y2, float *z)
vtkOpenGLRenderWindow::DestroyHardwareOffScreenWindow
void DestroyHardwareOffScreenWindow()
vtkOpenGLRenderWindow::MaximumHardwareLineWidth
float MaximumHardwareLineWidth
Definition: vtkOpenGLRenderWindow.h:313
vtkOpenGLRenderWindow::DrawPixels
virtual void DrawPixels(int srcWidth, int srcHeight, int numComponents, int dataType, void *data)
vtkOpenGLRenderWindow::SetPixelData
virtual int SetPixelData(int x, int y, int x2, int y2, vtkUnsignedCharArray *data, int front)
vtkFloatArray
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:49
vtkOpenGLRenderWindow::SetRGBAPixelData
virtual int SetRGBAPixelData(int x, int y, int x2, int y2, float *data, int front, int blend=0)
vtkOpenGLRenderWindow::TextureResourceIds
std::map< const vtkTextureObject *, int > TextureResourceIds
Definition: vtkOpenGLRenderWindow.h:237
vtkTimeStamp
record modification and/or execution time
Definition: vtkTimeStamp.h:35
vtkOpenGLRenderWindow::GetLastGraphicErrorString
virtual const char * GetLastGraphicErrorString()
vtkOpenGLRenderWindow::SetTextureUnitManager
void SetTextureUnitManager(vtkTextureUnitManager *textureUnitManager)
vtkUnsignedCharArray
dynamic, self-adjusting array of unsigned char
Definition: vtkUnsignedCharArray.h:49
vtkTypeMacro
#define vtkTypeMacro(thisClass, superclass)
Definition: vtkSetGet.h:642
vtkRenderWindow.h
vtkOpenGLRenderWindow::CreateHardwareOffScreenWindow
int CreateHardwareOffScreenWindow(int width, int height)
vtkOpenGLRenderWindow::DrawPixelsTextureObject
vtkTextureObject * DrawPixelsTextureObject
Definition: vtkOpenGLRenderWindow.h:309
vtkgl::x
GLint GLint GLint GLint GLint x
Definition: vtkgl.h:11318
vtkOpenGLRenderWindow::GetContextCreationTime
virtual unsigned long GetContextCreationTime()
vtkOpenGLRenderWindow::GetBackLeftBuffer
unsigned int GetBackLeftBuffer()
vtkOpenGLRenderWindow::SetRGBACharPixelData
virtual int SetRGBACharPixelData(int x, int y, int x2, int y2, unsigned char *data, int front, int blend=0)
vtkOpenGLRenderWindow::GetBackRightBuffer
unsigned int GetBackRightBuffer()
vtkOpenGLRenderWindow::DrawPixels
virtual void DrawPixels(int dstXmin, int dstYmin, int dstXmax, int dstYmax, int srcXmin, int srcYmin, int srcXmax, int srcYmax, int srcWidth, int srcHeight, int numComponents, int dataType, void *data)
vtkOpenGLRenderWindow::~vtkOpenGLRenderWindow
~vtkOpenGLRenderWindow()
vtkOpenGLRenderWindow::GetZbufferData
virtual int GetZbufferData(int x1, int y1, int x2, int y2, vtkFloatArray *z)
vtkOpenGLRenderWindow::SetRGBACharPixelData
virtual int SetRGBACharPixelData(int x, int y, int x2, int y2, vtkUnsignedCharArray *data, int front, int blend=0)
vtkOpenGLRenderWindow::SetContextSupportsOpenGL32
void SetContextSupportsOpenGL32(bool val)
vtkOpenGLRenderWindow::GetRGBACharPixelData
virtual unsigned char * GetRGBACharPixelData(int x, int y, int x2, int y2, int front)
vtkgl::val
GLuint GLfloat * val
Definition: vtkgl.h:13789
vtkOpenGLRenderWindow::SaveGLState
void SaveGLState()
vtkOpenGLRenderWindow::GetZbufferData
virtual float * GetZbufferData(int x1, int y1, int x2, int y2)
vtkOpenGLRenderWindow::GetRGBAPixelData
int GetRGBAPixelData(int x, int y, int x2, int y2, int front, float *data)
vtkTexture
handles properties associated with a texture map
Definition: vtkTexture.h:70
vtkTextureUnitManager
allocate/free texture units.
Definition: vtkTextureUnitManager.h:38
vtkOpenGLRenderWindow::ShaderCache
vtkOpenGLShaderCache * ShaderCache
Definition: vtkOpenGLRenderWindow.h:233
vtkOpenGLRenderWindow::WaitForCompletion
virtual void WaitForCompletion()
vtkOpenGLRenderWindow::ReleaseGraphicsResources
virtual void ReleaseGraphicsResources()
vtkOpenGLRenderWindow::GetPixelData
virtual int GetPixelData(int x, int y, int x2, int y2, int front, vtkUnsignedCharArray *data)
vtkOpenGLRenderWindow::DeactivateTexture
void DeactivateTexture(vtkTextureObject *)
vtkOpenGLRenderWindow::GetTextureUnitForTexture
int GetTextureUnitForTexture(vtkTextureObject *)
vtkOpenGLHardwareSupport
OpenGL rendering window.
Definition: vtkOpenGLHardwareSupport.h:38
vtkOpenGLRenderWindow::GetPixelData
virtual unsigned char * GetPixelData(int x, int y, int x2, int y2, int front)
vtkOpenGLRenderWindow::GetPixelData
int GetPixelData(int x, int y, int x2, int y2, int front, unsigned char *data)
vtkOpenGLRenderWindow::OpenGLInitState
virtual void OpenGLInitState()
vtkShaderProgram
The ShaderProgram uses one or more Shader objects.
Definition: vtkShaderProgram.h:43
vtkOpenGLRenderWindow::OpenGLInitContext
virtual void OpenGLInitContext()
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:39
vtkTextureObject
abstracts an OpenGL texture object.
Definition: vtkTextureObject.h:40
vtkOpenGLRenderWindow::GetContextSupportsOpenGL32
static bool GetContextSupportsOpenGL32()
vtkOpenGLRenderWindow::StereoUpdate
virtual void StereoUpdate()
vtkOpenGLRenderWindow::GetFrontBuffer
unsigned int GetFrontBuffer()
vtkIdList
list of point or cell ids
Definition: vtkIdList.h:36
vtkOpenGLRenderWindow::SetZbufferData
virtual int SetZbufferData(int x1, int y1, int x2, int y2, vtkFloatArray *buffer)
vtkOpenGLRenderWindow::Render
void Render()
vtkOpenGLShaderCache
manage Shader Programs within a context
Definition: vtkOpenGLShaderCache.h:33
vtkOpenGLRenderWindow::GetBackBuffer
unsigned int GetBackBuffer()
vtkOpenGLRenderWindow::GetTextureUnitManager
vtkTextureUnitManager * GetTextureUnitManager()
vtkOpenGLRenderWindow::RestoreGLState
void RestoreGLState()
vtkOpenGLRenderWindow::Initialized
bool Initialized
Definition: vtkOpenGLRenderWindow.h:311
vtkgl::width
GLint GLint GLsizei width
Definition: vtkgl.h:11316
vtkOpenGLRenderWindow::GetFrontLeftBuffer
unsigned int GetFrontLeftBuffer()
VTK_LEGACY
#define VTK_LEGACY(method)
Definition: vtkSetGet.h:801
vtkOpenGLRenderWindow::GetFrontRightBuffer
unsigned int GetFrontRightBuffer()
vtkgl::y
GLint GLint GLint GLint GLint GLint y
Definition: vtkgl.h:11318
vtkgl::buffer
GLuint buffer
Definition: vtkgl.h:11839
vtkOpenGLRenderWindow::GetRGBAPixelData
virtual float * GetRGBAPixelData(int x, int y, int x2, int y2, int front)
vtkOpenGLRenderWindow::vtkOpenGLRenderWindow
vtkOpenGLRenderWindow()
vtkOpenGLRenderWindow::DestroyWindow
virtual void DestroyWindow()=0
vtkOpenGLRenderWindow::GetGlobalMaximumNumberOfMultiSamples
static int GetGlobalMaximumNumberOfMultiSamples()
vtkOpenGLRenderWindow::GLStateIntegers
std::map< std::string, int > GLStateIntegers
Definition: vtkOpenGLRenderWindow.h:286
vtkOpenGLRenderWindow::GetColorBufferSizes
int GetColorBufferSizes(int *rgba)
vtkOpenGLRenderWindow::CheckGraphicError
virtual void CheckGraphicError()
vtkOpenGLRenderWindow
OpenGL rendering window.
Definition: vtkOpenGLRenderWindow.h:41
vtkOpenGLRenderWindow::ReleaseRGBAPixelData
virtual void ReleaseRGBAPixelData(float *data)
vtkOpenGLRenderWindow::GetDepthBufferSize
int GetDepthBufferSize()
vtkRenderWindow
create a window for renderers to draw into
Definition: vtkRenderWindow.h:89
vtkStdString
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:48
vtkOpenGLRenderWindow::GetRGBAPixelData
virtual int GetRGBAPixelData(int x, int y, int x2, int y2, int front, vtkFloatArray *data)
vtkOpenGLRenderWindow::SetGlobalMaximumNumberOfMultiSamples
static void SetGlobalMaximumNumberOfMultiSamples(int val)
vtkOpenGLRenderWindow::SetRGBAPixelData
virtual int SetRGBAPixelData(int x, int y, int x2, int y2, vtkFloatArray *data, int front, int blend=0)
vtkOpenGLVertexArrayObject
The VertexArrayObject class uses, or emulates, vertex array objects.
Definition: vtkOpenGLVertexArrayObject.h:36
vtkOpenGLRenderWindow::GetRGBACharPixelData
virtual int GetRGBACharPixelData(int x, int y, int x2, int y2, int front, vtkUnsignedCharArray *data)
vtkOpenGLRenderWindow::HasGraphicError
virtual int HasGraphicError()
vtkOpenGLRenderWindow::CreateAWindow
virtual void CreateAWindow()=0
vtkOpenGLRenderWindow::LastGraphicError
unsigned int LastGraphicError
Definition: vtkOpenGLRenderWindow.h:298
vtkOpenGLRenderWindow::GetRGBACharPixelData
int GetRGBACharPixelData(int x, int y, int x2, int y2, int front, unsigned char *data)
vtkgl::height
GLint GLint GLsizei GLsizei height
Definition: vtkgl.h:11316