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) override;
46 
48 
51  static void SetGlobalMaximumNumberOfMultiSamples(int val);
52  static int GetGlobalMaximumNumberOfMultiSamples();
54 
58  const char *GetRenderingBackend() override;
59 
61 
64  unsigned char *GetPixelData(int x,int y,int x2,int y2,int front,int right=0)
65  override;
66  int GetPixelData(int x,int y,int x2,int y2, int front,
67  vtkUnsignedCharArray *data, int right=0) override;
68  int SetPixelData(int x,int y,int x2,int y2,unsigned char *data,
69  int front, int right=0) override;
70  int SetPixelData(int x,int y,int x2,int y2,
71  vtkUnsignedCharArray *data, int front, int right=0)
72  override;
74 
76 
79  float *GetRGBAPixelData(int x,int y,int x2,int y2,int front,int right=0)
80  override;
81  int GetRGBAPixelData(int x,int y,int x2,int y2, int front,
82  vtkFloatArray* data, int right=0) override;
83  int SetRGBAPixelData(int x,int y,int x2,int y2, float *data,
84  int front, int blend=0, int right=0) override;
85  int SetRGBAPixelData(int x,int y,int x2,int y2, vtkFloatArray *data,
86  int front, int blend=0,int right=0) override;
87  void ReleaseRGBAPixelData(float *data) override;
88  unsigned char *GetRGBACharPixelData(int x,int y,int x2,int y2,
89  int front, int right=0) override;
90  int GetRGBACharPixelData(int x,int y,int x2,int y2, int front,
91  vtkUnsignedCharArray *data,int right=0) override;
92  int SetRGBACharPixelData(int x, int y, int x2, int y2,
93  unsigned char *data, int front,
94  int blend=0,int right=0) override;
95  int SetRGBACharPixelData(int x,int y,int x2,int y2,
96  vtkUnsignedCharArray *data, int front,
97  int blend=0, int right=0) override;
99 
101 
104  float *GetZbufferData( int x1, int y1, int x2, int y2 ) override;
105  int GetZbufferData( int x1, int y1, int x2, int y2, float* z ) override;
106  int GetZbufferData( int x1, int y1, int x2, int y2,
107  vtkFloatArray* z ) override;
108  int SetZbufferData( int x1, int y1, int x2, int y2, float *buffer ) override;
109  int SetZbufferData( int x1, int y1, int x2, int y2,
110  vtkFloatArray *buffer ) override;
112 
116  void RegisterTextureResource (GLuint id);
117 
121  int GetDepthBufferSize() override;
122 
127  int GetColorBufferSizes(int *rgba) override;
128 
130 
133  void SetSize(int a[2]) override;
134  void SetSize(int,int) override;
136 
140  virtual void OpenGLInit();
141 
142  // Initialize the state of OpenGL that VTK wants for this window
143  virtual void OpenGLInitState();
144 
145  // Initialize VTK for rendering in a new OpenGL context
146  virtual void OpenGLInitContext();
147 
155  unsigned int GetBackLeftBuffer();
156 
164  unsigned int GetBackRightBuffer();
165 
173  unsigned int GetFrontLeftBuffer();
174 
182  unsigned int GetFrontRightBuffer();
183 
191  unsigned int GetBackBuffer();
192 
200  unsigned int GetFrontBuffer();
201 
205  virtual vtkMTimeType GetContextCreationTime();
206 
211  vtkOpenGLExtensionManager* GetExtensionManager();
212 
217  vtkOpenGLHardwareSupport* GetHardwareSupport();
218 
223  vtkTextureUnitManager *GetTextureUnitManager();
224 
229  void WaitForCompletion() override;
230 
232 
240  int SetUseOffScreenBuffers(bool offScreen) override;
241  bool GetUseOffScreenBuffers() override;
243 
244 protected:
246  ~vtkOpenGLRenderWindow() override;
247 
250 
251  int GetPixelData(int x, int y, int x2, int y2, int front, unsigned char* data, int right=0);
252  int GetRGBAPixelData(int x, int y, int x2, int y2, int front, float* data, int right=0);
253  int GetRGBACharPixelData(int x, int y, int x2, int y2, int front,
254  unsigned char* data, int right=0);
255 
265  int CreateHardwareOffScreenWindow(int width, int height);
266 
267  int CreateHardwareOffScreenBuffers(int width, int height, bool bind = false);
268  void BindHardwareOffScreenBuffers();
269 
275  void DestroyHardwareOffScreenWindow();
276 
277  void UnbindHardwareOffScreenBuffers();
278  void DestroyHardwareOffScreenBuffers();
279 
284 
286 
290  unsigned int TextureObjects[4]; // really GLuint
291  unsigned int FrameBufferObject; // really GLuint
292  unsigned int DepthRenderBufferObject; // really GLuint
293  int HardwareBufferSize[2];
296 
300  virtual void CreateAWindow() = 0;
301 
305  virtual void DestroyWindow() = 0;
306 
310  void SetTextureUnitManager(vtkTextureUnitManager *textureUnitManager);
311 
312  unsigned int BackLeftBuffer;
313  unsigned int BackRightBuffer;
314  unsigned int FrontLeftBuffer;
315  unsigned int FrontRightBuffer;
316  unsigned int FrontBuffer;
317  unsigned int BackBuffer;
318 
323 
325 
327 
328 private:
330  void operator=(const vtkOpenGLRenderWindow&) = delete;
331 
332  void SetExtensionManager(vtkOpenGLExtensionManager*);
333  void SetHardwareSupport(vtkOpenGLHardwareSupport * renderWindow);
334 
335  vtkOpenGLExtensionManager* ExtensionManager;
336  vtkOpenGLHardwareSupport* HardwareSupport;
337 };
338 
339 #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().