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 =========================================================================*/
28 #ifndef vtkOpenGLRenderWindow_h
29 #define vtkOpenGLRenderWindow_h
30 
31 #include "vtkRenderingOpenGLModule.h" // For export macro
32 #include "vtkRenderWindow.h"
33 #include "vtkOpenGL.h" // Needed for GLuint.
34 
35 class vtkIdList;
39 class vtkStdString;
40 
41 class VTKRENDERINGOPENGL_EXPORT vtkOpenGLRenderWindow : public vtkRenderWindow
42 {
43 public:
45  void PrintSelf(ostream& os, vtkIndent indent);
46 
48 
51  static void SetGlobalMaximumNumberOfMultiSamples(int val);
52  static int GetGlobalMaximumNumberOfMultiSamples();
54 
58  virtual const char *GetRenderingBackend();
59 
63  virtual void StereoUpdate();
64 
66 
69  virtual unsigned char *GetPixelData(int x,int y,int x2,int y2,int front);
70  virtual int GetPixelData(int x,int y,int x2,int y2, int front,
72  virtual int SetPixelData(int x,int y,int x2,int y2,unsigned char *data,
73  int front);
74  virtual int SetPixelData(int x,int y,int x2,int y2,
75  vtkUnsignedCharArray *data, int front);
77 
79 
82  virtual float *GetRGBAPixelData(int x,int y,int x2,int y2,int front);
83  virtual int GetRGBAPixelData(int x,int y,int x2,int y2, int front,
85  virtual int SetRGBAPixelData(int x,int y,int x2,int y2, float *data,
86  int front, int blend=0);
87  virtual int SetRGBAPixelData(int x,int y,int x2,int y2, vtkFloatArray *data,
88  int front, int blend=0);
89  virtual void ReleaseRGBAPixelData(float *data);
90  virtual unsigned char *GetRGBACharPixelData(int x,int y,int x2,int y2,
91  int front);
92  virtual int GetRGBACharPixelData(int x,int y,int x2,int y2, int front,
94  virtual int SetRGBACharPixelData(int x, int y, int x2, int y2,
95  unsigned char *data, int front,
96  int blend=0);
97  virtual int SetRGBACharPixelData(int x,int y,int x2,int y2,
98  vtkUnsignedCharArray *data, int front,
99  int blend=0);
101 
103 
106  virtual float *GetZbufferData( int x1, int y1, int x2, int y2 );
107  virtual int GetZbufferData( int x1, int y1, int x2, int y2, float* z );
108  virtual int GetZbufferData( int x1, int y1, int x2, int y2,
109  vtkFloatArray* z );
110  virtual int SetZbufferData( int x1, int y1, int x2, int y2, float *buffer );
111  virtual int SetZbufferData( int x1, int y1, int x2, int y2,
112  vtkFloatArray *buffer );
114 
118  void RegisterTextureResource (GLuint id);
119 
123  int GetDepthBufferSize();
124 
129  int GetColorBufferSizes(int *rgba);
130 
132 
135  virtual void SetSize(int a[2]);
136  virtual void SetSize(int,int);
138 
142  virtual void OpenGLInit();
143 
144  // Initialize the state of OpenGL that VTK wants for this window
145  virtual void OpenGLInitState();
146 
147  // Initialize VTK for rendering in a new OpenGL context
148  virtual void OpenGLInitContext();
149 
157  unsigned int GetBackLeftBuffer();
158 
166  unsigned int GetBackRightBuffer();
167 
175  unsigned int GetFrontLeftBuffer();
176 
184  unsigned int GetFrontRightBuffer();
185 
193  unsigned int GetBackBuffer();
194 
202  unsigned int GetFrontBuffer();
203 
207  virtual vtkMTimeType GetContextCreationTime();
208 
213  vtkOpenGLExtensionManager* GetExtensionManager();
214 
219  vtkOpenGLHardwareSupport* GetHardwareSupport();
220 
225  vtkTextureUnitManager *GetTextureUnitManager();
226 
231  virtual void WaitForCompletion();
232 
234 
242  virtual int SetUseOffScreenBuffers(bool offScreen);
243  virtual bool GetUseOffScreenBuffers();
245 
246 protected:
249 
252 
253  int GetPixelData(int x, int y, int x2, int y2, int front, unsigned char* data);
254  int GetRGBAPixelData(int x, int y, int x2, int y2, int front, float* data);
255  int GetRGBACharPixelData(int x, int y, int x2, int y2, int front,
256  unsigned char* data);
257 
267  int CreateHardwareOffScreenWindow(int width, int height);
268 
269  int CreateHardwareOffScreenBuffers(int width, int height, bool bind = false);
270  void BindHardwareOffScreenBuffers();
271 
277  void DestroyHardwareOffScreenWindow();
278 
279  void UnbindHardwareOffScreenBuffers();
280  void DestroyHardwareOffScreenBuffers();
281 
286 
288 
292  unsigned int TextureObjects[4]; // really GLuint
293  unsigned int FrameBufferObject; // really GLuint
294  unsigned int DepthRenderBufferObject; // really GLuint
295  int HardwareBufferSize[2];
298 
302  virtual void CreateAWindow() = 0;
303 
307  virtual void DestroyWindow() = 0;
308 
312  void SetTextureUnitManager(vtkTextureUnitManager *textureUnitManager);
313 
314  unsigned int BackLeftBuffer;
315  unsigned int BackRightBuffer;
316  unsigned int FrontLeftBuffer;
317  unsigned int FrontRightBuffer;
318  unsigned int FrontBuffer;
319  unsigned int BackBuffer;
320 
325 
327 
329 
330 private:
331  vtkOpenGLRenderWindow(const vtkOpenGLRenderWindow&) VTK_DELETE_FUNCTION;
332  void operator=(const vtkOpenGLRenderWindow&) VTK_DELETE_FUNCTION;
333 
334  void SetExtensionManager(vtkOpenGLExtensionManager*);
335  void SetHardwareSupport(vtkOpenGLHardwareSupport * renderWindow);
336 
337  vtkOpenGLExtensionManager* ExtensionManager;
338  vtkOpenGLHardwareSupport* HardwareSupport;
339 };
340 
341 #endif
vtkWindow::SetSize
virtual void SetSize(int, int)
vtkRenderWindow::SetRGBACharPixelData
virtual int SetRGBACharPixelData(int x, int y, int x2, int y2, unsigned char *data, int front, int blend=0)=0
vtkOpenGLRenderWindow::NumberOfFrameBuffers
int NumberOfFrameBuffers
Variables used by the framebuffer-based offscreen method.
Definition: vtkOpenGLRenderWindow.h:291
vtkRenderWindow::GetUseOffScreenBuffers
virtual bool GetUseOffScreenBuffers()
Definition: vtkRenderWindow.h:724
vtkRenderWindow::GetColorBufferSizes
virtual int GetColorBufferSizes(int *rgba)=0
Get the size of the color buffer.
vtkRenderWindow::GetDepthBufferSize
virtual int GetDepthBufferSize()=0
This method should be defined by the subclass.
vtkFloatArray
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:41
vtkX3D::data
@ data
Definition: vtkX3D.h:315
vtkRenderWindow::SetRGBAPixelData
virtual int SetRGBAPixelData(int x, int y, int x2, int y2, float *, int front, int blend=0)=0
vtkTimeStamp
record modification and/or execution time
Definition: vtkTimeStamp.h:35
vtkRenderWindow::SetUseOffScreenBuffers
virtual int SetUseOffScreenBuffers(bool)
Create and bind offscreen rendering buffers without destroying the current OpenGL context.
Definition: vtkRenderWindow.h:723
vtkOpenGLRenderWindow::TextureUnitManager
vtkTextureUnitManager * TextureUnitManager
Definition: vtkOpenGLRenderWindow.h:328
vtkUnsignedCharArray
dynamic, self-adjusting array of unsigned char
Definition: vtkUnsignedCharArray.h:41
vtkRenderWindow.h
vtkOpenGLRenderWindow::OldMonitorSetting
long OldMonitorSetting
Definition: vtkOpenGLRenderWindow.h:250
vtkOpenGLRenderWindow::FrameBufferObject
unsigned int FrameBufferObject
Definition: vtkOpenGLRenderWindow.h:293
vtkOpenGLRenderWindow::OffScreenUseFrameBuffer
int OffScreenUseFrameBuffer
Flag telling if a framebuffer-based offscreen is currently in use.
Definition: vtkOpenGLRenderWindow.h:285
vtkOpenGLRenderWindow::FrontRightBuffer
unsigned int FrontRightBuffer
Definition: vtkOpenGLRenderWindow.h:317
vtkOpenGLRenderWindow::FrontBuffer
unsigned int FrontBuffer
Definition: vtkOpenGLRenderWindow.h:318
vtkMTimeType
vtkTypeUInt64 vtkMTimeType
Definition: vtkType.h:248
vtkOpenGLRenderWindow::ContextCreationTime
vtkTimeStamp ContextCreationTime
Definition: vtkOpenGLRenderWindow.h:326
vtkOpenGLExtensionManager
Interface class for querying and using OpenGL extensions.
vtkTextureUnitManager
allocate/free texture units.
Definition: vtkTextureUnitManager.h:38
vtkOpenGLRenderWindow::HardwareOffScreenBuffersBind
bool HardwareOffScreenBuffersBind
Definition: vtkOpenGLRenderWindow.h:296
vtkX3D::height
@ height
Definition: vtkX3D.h:254
vtkOpenGLHardwareSupport
OpenGL rendering window.
Definition: vtkOpenGLHardwareSupport.h:37
vtkOpenGLRenderWindow::OwnContext
int OwnContext
Flag telling if the context has been created here or was inherited.
Definition: vtkOpenGLRenderWindow.h:324
vtkRenderWindow::GetZbufferData
virtual float * GetZbufferData(int x, int y, int x2, int y2)=0
Set/Get the zbuffer data from the frame buffer.
vtkRenderWindow::GetRGBACharPixelData
virtual unsigned char * GetRGBACharPixelData(int x, int y, int x2, int y2, int front)=0
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:39
vtkOpenGLRenderWindow::FrontLeftBuffer
unsigned int FrontLeftBuffer
Definition: vtkOpenGLRenderWindow.h:316
vtkIdList
list of point or cell ids
Definition: vtkIdList.h:36
vtkRenderWindow::WaitForCompletion
virtual void WaitForCompletion()=0
Block the thread until the actual rendering is finished().
vtkRenderWindow::SetPixelData
virtual int SetPixelData(int x, int y, int x2, int y2, unsigned char *data, int front)=0
Set/Get the pixel data of an image, transmitted as RGBRGBRGB.
vtkWindow::GetPixelData
virtual unsigned char * GetPixelData(int x, int y, int x2, int y2, int front)=0
Get the pixel data of an image, transmitted as RGBRGBRGB.
vtkRenderWindow::SetZbufferData
virtual int SetZbufferData(int x, int y, int x2, int y2, float *z)=0
vtkOpenGLRenderWindow::BackRightBuffer
unsigned int BackRightBuffer
Definition: vtkOpenGLRenderWindow.h:315
vtkRenderWindow::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent)
Methods invoked by print to print information about the object including superclasses.
vtkRenderWindow::StereoUpdate
virtual void StereoUpdate()
Update the system, if needed, due to stereo rendering.
vtkRenderWindow::ReleaseRGBAPixelData
virtual void ReleaseRGBAPixelData(float *data)=0
vtkOpenGLRenderWindow::BackLeftBuffer
unsigned int BackLeftBuffer
Definition: vtkOpenGLRenderWindow.h:314
vtkOpenGLRenderWindow
OpenGL rendering window.
Definition: vtkOpenGLRenderWindow.h:41
vtkRenderWindow
create a window for renderers to draw into
Definition: vtkRenderWindow.h:86
vtkRenderWindow::GetRenderingBackend
virtual const char * GetRenderingBackend()
What rendering backend has the user requested.
vtkStdString
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:47
vtkOpenGLRenderWindow::DepthRenderBufferObject
unsigned int DepthRenderBufferObject
Definition: vtkOpenGLRenderWindow.h:294
vtkOpenGLRenderWindow::BackBuffer
unsigned int BackBuffer
Definition: vtkOpenGLRenderWindow.h:319
vtkOpenGLRenderWindow::TextureResourceIds
vtkIdList * TextureResourceIds
Definition: vtkOpenGLRenderWindow.h:251
vtkOpenGL.h
vtkRenderWindow::GetRGBAPixelData
virtual float * GetRGBAPixelData(int x, int y, int x2, int y2, int front)=0
Same as Get/SetPixelData except that the image also contains an alpha component.