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 =========================================================================*/
25 #ifndef vtkOpenGLRenderWindow_h
26 #define vtkOpenGLRenderWindow_h
27 
28 #include "vtkRenderingOpenGLModule.h" // For export macro
29 #include "vtkRenderWindow.h"
30 #include "vtkOpenGL.h" // Needed for GLuint.
31 
32 class vtkIdList;
36 class vtkStdString;
37 
38 class VTKRENDERINGOPENGL_EXPORT vtkOpenGLRenderWindow : public vtkRenderWindow
39 {
40 public:
42  void PrintSelf(ostream& os, vtkIndent indent);
43 
45 
51 
55  virtual const char *GetRenderingBackend();
56 
60  virtual void StereoUpdate();
61 
63 
66  virtual unsigned char *GetPixelData(int x,int y,int x2,int y2,int front);
67  virtual int GetPixelData(int x,int y,int x2,int y2, int front,
69  virtual int SetPixelData(int x,int y,int x2,int y2,unsigned char *data,
70  int front);
71  virtual int SetPixelData(int x,int y,int x2,int y2,
72  vtkUnsignedCharArray *data, int front);
74 
76 
79  virtual float *GetRGBAPixelData(int x,int y,int x2,int y2,int front);
80  virtual int GetRGBAPixelData(int x,int y,int x2,int y2, int front,
82  virtual int SetRGBAPixelData(int x,int y,int x2,int y2, float *data,
83  int front, int blend=0);
84  virtual int SetRGBAPixelData(int x,int y,int x2,int y2, vtkFloatArray *data,
85  int front, int blend=0);
86  virtual void ReleaseRGBAPixelData(float *data);
87  virtual unsigned char *GetRGBACharPixelData(int x,int y,int x2,int y2,
88  int front);
89  virtual int GetRGBACharPixelData(int x,int y,int x2,int y2, int front,
91  virtual int SetRGBACharPixelData(int x, int y, int x2, int y2,
92  unsigned char *data, int front,
93  int blend=0);
94  virtual int SetRGBACharPixelData(int x,int y,int x2,int y2,
95  vtkUnsignedCharArray *data, int front,
96  int blend=0);
98 
100 
103  virtual float *GetZbufferData( int x1, int y1, int x2, int y2 );
104  virtual int GetZbufferData( int x1, int y1, int x2, int y2, float* z );
105  virtual int GetZbufferData( int x1, int y1, int x2, int y2,
106  vtkFloatArray* z );
107  virtual int SetZbufferData( int x1, int y1, int x2, int y2, float *buffer );
108  virtual int SetZbufferData( int x1, int y1, int x2, int y2,
109  vtkFloatArray *buffer );
111 
115  void RegisterTextureResource (GLuint id);
116 
121 
126  int GetColorBufferSizes(int *rgba);
127 
129 
132  virtual void SetSize(int a[2]);
133  virtual void SetSize(int,int);
135 
139  virtual void OpenGLInit();
140 
141  // Initialize the state of OpenGL that VTK wants for this window
142  virtual void OpenGLInitState();
143 
144  // Initialize VTK for rendering in a new OpenGL context
145  virtual void OpenGLInitContext();
146 
154  unsigned int GetBackLeftBuffer();
155 
163  unsigned int GetBackRightBuffer();
164 
172  unsigned int GetFrontLeftBuffer();
173 
181  unsigned int GetFrontRightBuffer();
182 
190  unsigned int GetBackBuffer();
191 
199  unsigned int GetFrontBuffer();
200 
205 
211 
217 
223 
228  virtual void WaitForCompletion();
229 
231 
239  virtual int SetUseOffScreenBuffers(bool offScreen);
240  virtual bool GetUseOffScreenBuffers();
242 
243 protected:
246 
249 
250  int GetPixelData(int x, int y, int x2, int y2, int front, unsigned char* data);
251  int GetRGBAPixelData(int x, int y, int x2, int y2, int front, float* data);
252  int GetRGBACharPixelData(int x, int y, int x2, int y2, int front,
253  unsigned char* data);
254 
265 
266  int CreateHardwareOffScreenBuffers(int width, int height, bool bind = false);
268 
275 
278 
283 
285 
289  unsigned int TextureObjects[4]; // really GLuint
290  unsigned int FrameBufferObject; // really GLuint
291  unsigned int DepthRenderBufferObject; // really GLuint
292  int HardwareBufferSize[2];
295 
299  virtual void CreateAWindow() = 0;
300 
304  virtual void DestroyWindow() = 0;
305 
309  void SetTextureUnitManager(vtkTextureUnitManager *textureUnitManager);
310 
311  unsigned int BackLeftBuffer;
312  unsigned int BackRightBuffer;
313  unsigned int FrontLeftBuffer;
314  unsigned int FrontRightBuffer;
315  unsigned int FrontBuffer;
316  unsigned int BackBuffer;
317 
322 
324 
326 
327 private:
328  vtkOpenGLRenderWindow(const vtkOpenGLRenderWindow&) VTK_DELETE_FUNCTION;
329  void operator=(const vtkOpenGLRenderWindow&) VTK_DELETE_FUNCTION;
330 
331  void SetExtensionManager(vtkOpenGLExtensionManager*);
332  void SetHardwareSupport(vtkOpenGLHardwareSupport * renderWindow);
333 
334  vtkOpenGLExtensionManager* ExtensionManager;
335  vtkOpenGLHardwareSupport* HardwareSupport;
336 };
337 
338 #endif
vtkOpenGLRenderWindow::SetPixelData
virtual int SetPixelData(int x, int y, int x2, int y2, unsigned char *data, int front)
Set/Get the pixel data of an image, transmitted as RGBRGBRGB.
vtkOpenGLRenderWindow::GetContextCreationTime
virtual vtkMTimeType GetContextCreationTime()
Get the time when the OpenGL context was created.
vtkOpenGLRenderWindow::GetRenderingBackend
virtual const char * GetRenderingBackend()
What rendering backend has the user requested.
vtkOpenGLRenderWindow::OpenGLInit
virtual void OpenGLInit()
Initialize OpenGL for this window.
vtkOpenGLRenderWindow::DestroyHardwareOffScreenBuffers
void DestroyHardwareOffScreenBuffers()
vtkOpenGLRenderWindow::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent)
Methods invoked by print to print information about the object including superclasses.
vtkOpenGLRenderWindow::SetZbufferData
virtual int SetZbufferData(int x1, int y1, int x2, int y2, float *buffer)
vtkOpenGLRenderWindow::NumberOfFrameBuffers
int NumberOfFrameBuffers
Variables used by the framebuffer-based offscreen method.
Definition: vtkOpenGLRenderWindow.h:288
vtkOpenGLRenderWindow::GetZbufferData
virtual int GetZbufferData(int x1, int y1, int x2, int y2, float *z)
vtkOpenGLRenderWindow::DestroyHardwareOffScreenWindow
void DestroyHardwareOffScreenWindow()
Destroy an offscreen window based on OpenGL framebuffer extension.
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:42
vtkX3D::data
@ data
Definition: vtkX3D.h:315
vtkOpenGLRenderWindow::SetRGBAPixelData
virtual int SetRGBAPixelData(int x, int y, int x2, int y2, float *data, int front, int blend=0)
vtkOpenGLRenderWindow::SetUseOffScreenBuffers
virtual int SetUseOffScreenBuffers(bool offScreen)
Create and bind offscreen rendering buffers without destroying the current OpenGL context.
vtkTimeStamp
record modification and/or execution time
Definition: vtkTimeStamp.h:36
vtkOpenGLRenderWindow::SetTextureUnitManager
void SetTextureUnitManager(vtkTextureUnitManager *textureUnitManager)
Set the texture unit manager.
vtkOpenGLRenderWindow::TextureUnitManager
vtkTextureUnitManager * TextureUnitManager
Definition: vtkOpenGLRenderWindow.h:325
vtkUnsignedCharArray
dynamic, self-adjusting array of unsigned char
Definition: vtkUnsignedCharArray.h:42
vtkOpenGLRenderWindow::BindHardwareOffScreenBuffers
void BindHardwareOffScreenBuffers()
vtkRenderWindow.h
vtkOpenGLRenderWindow::OldMonitorSetting
long OldMonitorSetting
Definition: vtkOpenGLRenderWindow.h:247
vtkOpenGLRenderWindow::CreateHardwareOffScreenWindow
int CreateHardwareOffScreenWindow(int width, int height)
Create an offScreen window based on OpenGL framebuffer extension.
vtkOpenGLRenderWindow::FrameBufferObject
unsigned int FrameBufferObject
Definition: vtkOpenGLRenderWindow.h:290
vtkOpenGLRenderWindow::GetBackLeftBuffer
unsigned int GetBackLeftBuffer()
Return the OpenGL name of the back left buffer.
vtkOpenGLRenderWindow::SetRGBACharPixelData
virtual int SetRGBACharPixelData(int x, int y, int x2, int y2, unsigned char *data, int front, int blend=0)
vtkOpenGLRenderWindow::OffScreenUseFrameBuffer
int OffScreenUseFrameBuffer
Flag telling if a framebuffer-based offscreen is currently in use.
Definition: vtkOpenGLRenderWindow.h:282
vtkOpenGLRenderWindow::FrontRightBuffer
unsigned int FrontRightBuffer
Definition: vtkOpenGLRenderWindow.h:314
vtkOpenGLRenderWindow::GetBackRightBuffer
unsigned int GetBackRightBuffer()
Return the OpenGL name of the back right buffer.
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::FrontBuffer
unsigned int FrontBuffer
Definition: vtkOpenGLRenderWindow.h:315
vtkOpenGLRenderWindow::GetRGBACharPixelData
virtual unsigned char * GetRGBACharPixelData(int x, int y, int x2, int y2, int front)
vtkMTimeType
vtkTypeUInt64 vtkMTimeType
Definition: vtkType.h:248
vtkOpenGLRenderWindow::GetZbufferData
virtual float * GetZbufferData(int x1, int y1, int x2, int y2)
Set/Get the zbuffer data from an image.
vtkOpenGLRenderWindow::ContextCreationTime
vtkTimeStamp ContextCreationTime
Definition: vtkOpenGLRenderWindow.h:323
vtkOpenGLRenderWindow::GetRGBAPixelData
int GetRGBAPixelData(int x, int y, int x2, int y2, int front, float *data)
vtkOpenGLExtensionManager
Interface class for querying and using OpenGL extensions.
vtkTextureUnitManager
allocate/free texture units.
Definition: vtkTextureUnitManager.h:39
vtkOpenGLRenderWindow::WaitForCompletion
virtual void WaitForCompletion()
Block the thread until the actual rendering is finished().
vtkOpenGLRenderWindow::GetPixelData
virtual int GetPixelData(int x, int y, int x2, int y2, int front, vtkUnsignedCharArray *data)
vtkOpenGLRenderWindow::HardwareOffScreenBuffersBind
bool HardwareOffScreenBuffersBind
Definition: vtkOpenGLRenderWindow.h:293
vtkX3D::height
@ height
Definition: vtkX3D.h:254
vtkOpenGLHardwareSupport
OpenGL rendering window.
Definition: vtkOpenGLHardwareSupport.h:39
vtkOpenGLRenderWindow::GetPixelData
virtual unsigned char * GetPixelData(int x, int y, int x2, int y2, int front)
Set/Get the pixel data of an image, transmitted as RGBRGB...
vtkOpenGLRenderWindow::GetPixelData
int GetPixelData(int x, int y, int x2, int y2, int front, unsigned char *data)
vtkOpenGLRenderWindow::OpenGLInitState
virtual void OpenGLInitState()
vtkOpenGLRenderWindow::OwnContext
int OwnContext
Flag telling if the context has been created here or was inherited.
Definition: vtkOpenGLRenderWindow.h:321
vtkOpenGLRenderWindow::OpenGLInitContext
virtual void OpenGLInitContext()
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:40
vtkOpenGLRenderWindow::GetExtensionManager
vtkOpenGLExtensionManager * GetExtensionManager()
Returns the extension manager.
vtkOpenGLRenderWindow::StereoUpdate
virtual void StereoUpdate()
Update system if needed due to stereo rendering.
vtkOpenGLRenderWindow::GetFrontBuffer
unsigned int GetFrontBuffer()
Return the OpenGL name of the front left buffer.
vtkOpenGLRenderWindow::FrontLeftBuffer
unsigned int FrontLeftBuffer
Definition: vtkOpenGLRenderWindow.h:313
vtkIdList
list of point or cell ids
Definition: vtkIdList.h:37
vtkOpenGLRenderWindow::SetZbufferData
virtual int SetZbufferData(int x1, int y1, int x2, int y2, vtkFloatArray *buffer)
vtkOpenGLRenderWindow::GetBackBuffer
unsigned int GetBackBuffer()
Return the OpenGL name of the back left buffer.
vtkOpenGLRenderWindow::GetTextureUnitManager
vtkTextureUnitManager * GetTextureUnitManager()
Returns its texture unit manager object.
vtkOpenGLRenderWindow::RegisterTextureResource
void RegisterTextureResource(GLuint id)
Register a texture name with this render window.
vtkOpenGLRenderWindow::GetFrontLeftBuffer
unsigned int GetFrontLeftBuffer()
Return the OpenGL name of the front left buffer.
vtkOpenGLRenderWindow::CreateHardwareOffScreenBuffers
int CreateHardwareOffScreenBuffers(int width, int height, bool bind=false)
vtkOpenGLRenderWindow::GetFrontRightBuffer
unsigned int GetFrontRightBuffer()
Return the OpenGL name of the front right buffer.
vtkOpenGLRenderWindow::GetRGBAPixelData
virtual float * GetRGBAPixelData(int x, int y, int x2, int y2, int front)
Set/Get the pixel data of an image, transmitted as RGBARGBA...
vtkOpenGLRenderWindow::GetUseOffScreenBuffers
virtual bool GetUseOffScreenBuffers()
vtkOpenGLRenderWindow::BackRightBuffer
unsigned int BackRightBuffer
Definition: vtkOpenGLRenderWindow.h:312
vtkOpenGLRenderWindow::vtkOpenGLRenderWindow
vtkOpenGLRenderWindow()
vtkOpenGLRenderWindow::GetHardwareSupport
vtkOpenGLHardwareSupport * GetHardwareSupport()
Returns an Hardware Support object.
vtkOpenGLRenderWindow::DestroyWindow
virtual void DestroyWindow()=0
Destroy a not-off-screen window.
vtkOpenGLRenderWindow::GetGlobalMaximumNumberOfMultiSamples
static int GetGlobalMaximumNumberOfMultiSamples()
vtkOpenGLRenderWindow::GetColorBufferSizes
int GetColorBufferSizes(int *rgba)
Get the size of the color buffer.
vtkOpenGLRenderWindow::SetSize
virtual void SetSize(int, int)
vtkOpenGLRenderWindow::BackLeftBuffer
unsigned int BackLeftBuffer
Definition: vtkOpenGLRenderWindow.h:311
vtkOpenGLRenderWindow
OpenGL rendering window.
Definition: vtkOpenGLRenderWindow.h:39
vtkOpenGLRenderWindow::ReleaseRGBAPixelData
virtual void ReleaseRGBAPixelData(float *data)
vtkOpenGLRenderWindow::GetDepthBufferSize
int GetDepthBufferSize()
Get the size of the depth buffer.
vtkRenderWindow
create a window for renderers to draw into
Definition: vtkRenderWindow.h:87
vtkStdString
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:49
vtkOpenGLRenderWindow::DepthRenderBufferObject
unsigned int DepthRenderBufferObject
Definition: vtkOpenGLRenderWindow.h:291
vtkOpenGLRenderWindow::BackBuffer
unsigned int BackBuffer
Definition: vtkOpenGLRenderWindow.h:316
vtkOpenGLRenderWindow::GetRGBAPixelData
virtual int GetRGBAPixelData(int x, int y, int x2, int y2, int front, vtkFloatArray *data)
vtkOpenGLRenderWindow::UnbindHardwareOffScreenBuffers
void UnbindHardwareOffScreenBuffers()
vtkOpenGLRenderWindow::SetGlobalMaximumNumberOfMultiSamples
static void SetGlobalMaximumNumberOfMultiSamples(int val)
Set/Get the maximum number of multisamples.
vtkOpenGLRenderWindow::SetRGBAPixelData
virtual int SetRGBAPixelData(int x, int y, int x2, int y2, vtkFloatArray *data, int front, int blend=0)
vtkOpenGLRenderWindow::GetRGBACharPixelData
virtual int GetRGBACharPixelData(int x, int y, int x2, int y2, int front, vtkUnsignedCharArray *data)
vtkOpenGLRenderWindow::TextureResourceIds
vtkIdList * TextureResourceIds
Definition: vtkOpenGLRenderWindow.h:248
vtkOpenGLRenderWindow::CreateAWindow
virtual void CreateAWindow()=0
Create a not-off-screen window.
vtkOpenGL.h
vtkOpenGLRenderWindow::GetRGBACharPixelData
int GetRGBACharPixelData(int x, int y, int x2, int y2, int front, unsigned char *data)
vtkOpenGLRenderWindow::SetSize
virtual void SetSize(int a[2])
Set the size of the window in screen coordinates in pixels.