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);
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  vtkGetVector2Macro(LastSize,int);
188 
193  static bool IsSupported(vtkRenderWindow *renWin);
194 
199  int CheckFrameBufferStatus(unsigned int mode);
200 
201 protected:
205  static
206  bool LoadRequiredExtensions(vtkRenderWindow *renWin);
207 
208  // gen buffer (occurs when context is set)
209  void CreateFBO();
210 
211  // delete buffer (occurs during destruction or context swicth)
212  void DestroyFBO();
213 
214  // create texture or renderbuffer and attach
215  // if user provided a texture just use that
216  // mode specifies DRAW or READ
217  void CreateDepthBuffer(int width, int height, unsigned int mode);
218 
219  // create textures for each target and attach
220  // if user provided textures use those, if the user
221  // provides any then they need to provide all
222  // mode specifies DRAW or READ
223  void CreateColorBuffers(
224  int width,
225  int height,
226  unsigned int mode,
227  bool shaderSupportsTextureInt);
228 
229  // detach and delete our reference(s)
230  void DestroyDepthBuffer();
231  void DestroyColorBuffers();
232 
233  // glDrawBuffers
234  void ActivateBuffers();
235 
239  void DisplayFrameBufferAttachments();
240 
244  void DisplayFrameBufferAttachment(unsigned int uattachment);
245 
249  void DisplayDrawBuffers();
250 
254  void DisplayReadBuffer();
255 
259  void DisplayBuffer(int value);
260 
263 
265 
268  unsigned int FBOIndex;
270  unsigned int DepthBuffer;
271  unsigned int NumberOfRenderTargets;
272  int LastSize[2];
273  std::vector<unsigned int> UserZSlices;
274  std::vector<vtkSmartPointer<vtkTextureObject> > UserColorBuffers;
275  std::vector<vtkSmartPointer<vtkTextureObject> > ColorBuffers;
276  std::vector<unsigned int> ActiveBuffers;
279 
280 private:
281  vtkFrameBufferObject(const vtkFrameBufferObject&) VTK_DELETE_FUNCTION;
282  void operator=(const vtkFrameBufferObject&) VTK_DELETE_FUNCTION;
283 
284 };
285 
286 #endif
OpenGL rendering window.
std::vector< unsigned int > ActiveBuffers
unsigned int NumberOfRenderTargets
void SetActiveBuffer(unsigned int index)
Choose the buffers to render into.
vtkWeakPointer< vtkRenderWindow > Context
std::vector< vtkSmartPointer< vtkTextureObject > > ColorBuffers
abstract interface to OpenGL FBOs
std::vector< vtkSmartPointer< vtkTextureObject > > UserColorBuffers
a simple class to control print indentation
Definition: vtkIndent.h:39
vtkSmartPointer< vtkTextureObject > UserDepthBuffer
std::vector< unsigned int > UserZSlices
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's.
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
void PrintSelf(ostream &os, vtkIndent indent)
Methods invoked by print to print information about the object including superclasses.