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) override;
43 
45 
48  static void SetGlobalMaximumNumberOfMultiSamples(int val);
49  static int GetGlobalMaximumNumberOfMultiSamples();
51 
55  const char *GetRenderingBackend() override;
56 
58 
61  unsigned char *GetPixelData(int x,int y,int x2,int y2,int front,int right=0)
62  override;
63  int GetPixelData(int x,int y,int x2,int y2, int front,
64  vtkUnsignedCharArray *data, int right=0) override;
65  int SetPixelData(int x,int y,int x2,int y2,unsigned char *data,
66  int front, int right=0) override;
67  int SetPixelData(int x,int y,int x2,int y2,
68  vtkUnsignedCharArray *data, int front, int right=0)
69  override;
71 
73 
76  float *GetRGBAPixelData(int x,int y,int x2,int y2,int front,int right=0)
77  override;
78  int GetRGBAPixelData(int x,int y,int x2,int y2, int front,
79  vtkFloatArray* data, int right=0) override;
80  int SetRGBAPixelData(int x,int y,int x2,int y2, float *data,
81  int front, int blend=0, int right=0) override;
82  int SetRGBAPixelData(int x,int y,int x2,int y2, vtkFloatArray *data,
83  int front, int blend=0,int right=0) override;
84  void ReleaseRGBAPixelData(float *data) override;
85  unsigned char *GetRGBACharPixelData(int x,int y,int x2,int y2,
86  int front, int right=0) override;
87  int GetRGBACharPixelData(int x,int y,int x2,int y2, int front,
88  vtkUnsignedCharArray *data,int right=0) override;
89  int SetRGBACharPixelData(int x, int y, int x2, int y2,
90  unsigned char *data, int front,
91  int blend=0,int right=0) override;
92  int SetRGBACharPixelData(int x,int y,int x2,int y2,
93  vtkUnsignedCharArray *data, int front,
94  int blend=0, int right=0) override;
96 
98 
101  float *GetZbufferData( int x1, int y1, int x2, int y2 ) override;
102  int GetZbufferData( int x1, int y1, int x2, int y2, float* z ) override;
103  int GetZbufferData( int x1, int y1, int x2, int y2,
104  vtkFloatArray* z ) override;
105  int SetZbufferData( int x1, int y1, int x2, int y2, float *buffer ) override;
106  int SetZbufferData( int x1, int y1, int x2, int y2,
107  vtkFloatArray *buffer ) override;
109 
113  void RegisterTextureResource (GLuint id);
114 
118  int GetDepthBufferSize() override;
119 
124  int GetColorBufferSizes(int *rgba) override;
125 
127 
130  void SetSize(int a[2]) override;
131  void SetSize(int,int) override;
133 
137  virtual void OpenGLInit();
138 
139  // Initialize the state of OpenGL that VTK wants for this window
140  virtual void OpenGLInitState();
141 
142  // Initialize VTK for rendering in a new OpenGL context
143  virtual void OpenGLInitContext();
144 
152  unsigned int GetBackLeftBuffer();
153 
161  unsigned int GetBackRightBuffer();
162 
170  unsigned int GetFrontLeftBuffer();
171 
179  unsigned int GetFrontRightBuffer();
180 
188  unsigned int GetBackBuffer();
189 
197  unsigned int GetFrontBuffer();
198 
202  virtual vtkMTimeType GetContextCreationTime();
203 
208  vtkOpenGLExtensionManager* GetExtensionManager();
209 
214  vtkOpenGLHardwareSupport* GetHardwareSupport();
215 
220  vtkTextureUnitManager *GetTextureUnitManager();
221 
226  void WaitForCompletion() override;
227 
229 
237  int SetUseOffScreenBuffers(bool offScreen) override;
238  bool GetUseOffScreenBuffers() override;
240 
241 protected:
243  ~vtkOpenGLRenderWindow() override;
244 
247 
248  int GetPixelData(int x, int y, int x2, int y2, int front, unsigned char* data, int right=0);
249  int GetRGBAPixelData(int x, int y, int x2, int y2, int front, float* data, int right=0);
250  int GetRGBACharPixelData(int x, int y, int x2, int y2, int front,
251  unsigned char* data, int right=0);
252 
262  int CreateHardwareOffScreenWindow(int width, int height);
263 
264  int CreateHardwareOffScreenBuffers(int width, int height, bool bind = false);
265  void BindHardwareOffScreenBuffers();
266 
272  void DestroyHardwareOffScreenWindow();
273 
274  void UnbindHardwareOffScreenBuffers();
275  void DestroyHardwareOffScreenBuffers();
276 
281 
283 
287  unsigned int TextureObjects[4]; // really GLuint
288  unsigned int FrameBufferObject; // really GLuint
289  unsigned int DepthRenderBufferObject; // really GLuint
290  int HardwareBufferSize[2];
293 
297  virtual void CreateAWindow() = 0;
298 
302  virtual void DestroyWindow() = 0;
303 
307  void SetTextureUnitManager(vtkTextureUnitManager *textureUnitManager);
308 
309  unsigned int BackLeftBuffer;
310  unsigned int BackRightBuffer;
311  unsigned int FrontLeftBuffer;
312  unsigned int FrontRightBuffer;
313  unsigned int FrontBuffer;
314  unsigned int BackBuffer;
315 
320 
322 
324 
325 private:
327  void operator=(const vtkOpenGLRenderWindow&) = delete;
328 
329  void SetExtensionManager(vtkOpenGLExtensionManager*);
330  void SetHardwareSupport(vtkOpenGLHardwareSupport * renderWindow);
331 
332  vtkOpenGLExtensionManager* ExtensionManager;
333  vtkOpenGLHardwareSupport* HardwareSupport;
334 };
335 
336 #endif
OpenGL rendering window.
int OwnContext
Flag telling if the context has been created here or was inherited.
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:40
virtual unsigned char * GetPixelData(int x, int y, int x2, int y2, int front, int right=0)=0
Get the pixel data of an image, transmitted as RGBRGBRGB.
int OffScreenUseFrameBuffer
Flag telling if a framebuffer-based offscreen is currently in use.
virtual int SetUseOffScreenBuffers(bool)
Create and bind offscreen rendering buffers without destroying the current OpenGL context...
virtual int SetRGBAPixelData(int x, int y, int x2, int y2, float *, int front, int blend=0, int right=0)=0
Same as Get/SetPixelData except that the image also contains an alpha component.
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:300
int NumberOfFrameBuffers
Variables used by the framebuffer-based offscreen method.
bool HardwareOffScreenBuffersBind
Variables used by the framebuffer-based offscreen method.
record modification and/or execution time
Definition: vtkTimeStamp.h:35
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:41
virtual int GetColorBufferSizes(int *rgba)=0
Get the size of the color buffer.
vtkTextureUnitManager * TextureUnitManager
virtual int SetPixelData(int x, int y, int x2, int y2, unsigned char *data, int front, int right=0)=0
Set/Get the pixel data of an image, transmitted as RGBRGBRGB.
virtual void SetSize(int, int)
Set/Get the size of the window in screen coordinates in pixels.
virtual int SetRGBACharPixelData(int x, int y, int x2, int y2, unsigned char *data, int front, int blend=0, int right=0)=0
Same as Get/SetPixelData except that the image also contains an alpha component.
a simple class to control print indentation
Definition: vtkIndent.h:39
virtual float * GetRGBAPixelData(int x, int y, int x2, int y2, int front, int right=0)=0
Same as Get/SetPixelData except that the image also contains an alpha component.
virtual void ReleaseRGBAPixelData(float *data)=0
Same as Get/SetPixelData except that the image also contains an alpha component.
unsigned int FrameBufferObject
Variables used by the framebuffer-based offscreen method.
list of point or cell ids
Definition: vtkIdList.h:36
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
virtual int GetDepthBufferSize()=0
This method should be defined by the subclass.
virtual int SetZbufferData(int x, int y, int x2, int y2, float *z)=0
Set/Get the zbuffer data from the frame buffer.
Interface class for querying and using OpenGL extensions.
virtual unsigned char * GetRGBACharPixelData(int x, int y, int x2, int y2, int front, int right=0)=0
Same as Get/SetPixelData except that the image also contains an alpha component.
dynamic, self-adjusting array of unsigned char
allocate/free texture units.
create a window for renderers to draw into
OpenGL rendering window.
virtual const char * GetRenderingBackend()
What rendering backend has the user requested.
virtual float * GetZbufferData(int x, int y, int x2, int y2)=0
Set/Get the zbuffer data from the frame buffer.
unsigned int DepthRenderBufferObject
Variables used by the framebuffer-based offscreen method.
virtual bool GetUseOffScreenBuffers()
virtual void WaitForCompletion()=0
Block the thread until the actual rendering is finished().