VTK
vtkFrameBufferObject.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkFrameBufferObject.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 =========================================================================*/
29 #ifndef vtkFrameBufferObject_h
30 #define vtkFrameBufferObject_h
31 
33 #include "vtkRenderingOpenGLModule.h" // For export macro
34 #include "vtkSmartPointer.h" // needed for vtkSmartPointer.
35 #include "vtkWeakPointer.h" // needed for vtkWeakPointer.
36 
37 #include <vector> // for the lists of logical buffers.
38 
39 class vtkRenderWindow;
40 class vtkTextureObject;
41 class vtkRenderbuffer;
45 
46 class VTKRENDERINGOPENGL_EXPORT vtkFrameBufferObject : public vtkFrameBufferObjectBase
47 {
48 public:
49  static vtkFrameBufferObject* New();
51  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
52 
54 
61  void SetContext(vtkRenderWindow *context);
62  vtkRenderWindow *GetContext();
64 
66 
75  bool Start(int width, int height, bool shaderSupportsTextureInt);
76  bool StartNonOrtho(int width, int height, bool shaderSupportsTextureInt);
78 
89  void RenderQuad(int minX, int maxX, int minY, int maxY);
90 
94  void Bind();
95 
100  void UnBind();
101 
105  void SetActiveBuffer(unsigned int index)
106  {
107  this->SetActiveBuffers(1, &index);
108  }
109 
117  void SetActiveBuffers(int numbuffers, unsigned int indices[]);
118 
130  void SetColorBuffer(
131  unsigned int index,
132  vtkTextureObject *texture,
133  unsigned int zslice=0);
134 
135  vtkTextureObject *GetColorBuffer(unsigned int index);
136  void RemoveColorBuffer(unsigned int index);
137  void RemoveAllColorBuffers();
138 
140 
143  void SetDepthBuffer(vtkTextureObject *depthTexture);
144  void RemoveDepthBuffer();
146 
148 
152  vtkSetMacro(DepthBufferNeeded,bool);
153  vtkGetMacro(DepthBufferNeeded,bool);
155 
157 
164  void SetNumberOfRenderTargets(unsigned int);
165  vtkGetMacro(NumberOfRenderTargets,unsigned int);
167 
173  unsigned int GetMaximumNumberOfActiveTargets();
174 
180  unsigned int GetMaximumNumberOfRenderTargets();
181 
183 
186  int *GetLastSize() VTK_OVERRIDE
187  {
188  return this->LastSize;
189  }
190  void GetLastSize (int &_arg1, int &_arg2) VTK_OVERRIDE
191  {
192  _arg1 = this->LastSize[0];
193  _arg2 = this->LastSize[1];
194  }
195  void GetLastSize (int _arg[2]) VTK_OVERRIDE
196  {
197  this->GetLastSize(_arg[0], _arg[1]);
198  }
200 
205  static bool IsSupported(vtkRenderWindow *renWin);
206 
211  int CheckFrameBufferStatus(unsigned int mode);
212 
213 protected:
217  static
218  bool LoadRequiredExtensions(vtkRenderWindow *renWin);
219 
220  // gen buffer (occurs when context is set)
221  void CreateFBO();
222 
223  // delete buffer (occurs during destruction or context swicth)
224  void DestroyFBO();
225 
226  // create texture or renderbuffer and attach
227  // if user provided a texture just use that
228  // mode specifies DRAW or READ
229  void CreateDepthBuffer(int width, int height, unsigned int mode);
230 
231  // create textures for each target and attach
232  // if user provided textures use those, if the user
233  // provides any then they need to provide all
234  // mode specifies DRAW or READ
235  void CreateColorBuffers(
236  int width,
237  int height,
238  unsigned int mode,
239  bool shaderSupportsTextureInt);
240 
241  // detach and delete our reference(s)
242  void DestroyDepthBuffer();
243  void DestroyColorBuffers();
244 
245  // glDrawBuffers
246  void ActivateBuffers();
247 
251  void DisplayFrameBufferAttachments();
252 
256  void DisplayFrameBufferAttachment(unsigned int uattachment);
257 
261  void DisplayDrawBuffers();
262 
266  void DisplayReadBuffer();
267 
271  void DisplayBuffer(int value);
272 
274  ~vtkFrameBufferObject() VTK_OVERRIDE;
275 
277 
278  bool DepthBufferNeeded;
279  bool ColorBuffersDirty;
280  unsigned int FBOIndex;
281  int PreviousFBOIndex;
282  unsigned int DepthBuffer;
283  unsigned int NumberOfRenderTargets;
284  int LastSize[2];
285  std::vector<unsigned int> UserZSlices;
286  std::vector<vtkSmartPointer<vtkTextureObject> > UserColorBuffers;
288  std::vector<unsigned int> ActiveBuffers;
290  bool DepthBufferDirty;
291 
292 private:
293  vtkFrameBufferObject(const vtkFrameBufferObject&) VTK_DELETE_FUNCTION;
294  void operator=(const vtkFrameBufferObject&) VTK_DELETE_FUNCTION;
295 
296 };
297 
298 #endif
OpenGL rendering window.
virtual int * GetLastSize()=0
Dimensions in pixels of the framebuffer.
Hold a reference to a vtkObjectBase instance.
void SetActiveBuffer(unsigned int index)
Choose the buffers to render into.
int * GetLastSize() override
Dimensions in pixels of the framebuffer.
abstract interface to OpenGL FBOs
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
a simple class to control print indentation
Definition: vtkIndent.h:33
a weak reference to a vtkObject.
void GetLastSize(int _arg[2]) override
Dimensions in pixels of the framebuffer.
abstracts an OpenGL pixel buffer object.
Interface class for querying and using OpenGL extensions.
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
internal class which encapsulates OpenGL frame buffer object.
abstracts an OpenGL texture object.
create a window for renderers to draw into
Storage for FBO&#39;s.
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
void GetLastSize(int &_arg1, int &_arg2) override
Dimensions in pixels of the framebuffer.