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 =========================================================================*/
25 #ifndef __vtkFrameBufferObject_h
26 #define __vtkFrameBufferObject_h
27 
28 #include "vtkObject.h"
29 #include "vtkSmartPointer.h" // needed for vtkSmartPointer.
30 #include "vtkWeakPointer.h" // needed for vtkWeakPointer.
31 //BTX
32 #include <vtkstd/vector> // for the lists of logical buffers.
33 //ETX
34 
35 class vtkRenderWindow;
36 class vtkTextureObject;
38 
40 {
41 public:
42  static vtkFrameBufferObject* New();
44  void PrintSelf(ostream& os, vtkIndent indent);
45 
47 
51  void SetContext(vtkRenderWindow *context);
52  vtkRenderWindow *GetContext();
54 
56 
62  bool Start(int width,
63  int height,
64  bool shaderSupportsTextureInt);
65  bool StartNonOrtho(int width,
66  int height,
67  bool shaderSupportsTextureInt);
69 
71 
76  void RenderQuad(int minX,
77  int maxX,
78  int minY,
79  int maxY);
81 
84  void Bind();
85 
88  void UnBind();
89 
91 
92  void SetActiveBuffer(unsigned int index)
93  {
94  this->SetActiveBuffers(1, &index);
95  }
97 
99 
101  void SetActiveBuffers(int numbuffers,
102  unsigned int indices[]);
104 
105  // All user specified texture objects must match the FBO dimensions
106  // and must have been created by the time Start() gets called.
107  // If texture is a 3D texture, zslice identifies the zslice that will be
108  // attached to the color buffer.
109  // .SECTION Caveat
110  // Currently, 1D textures are not supported.
111  void SetColorBuffer(unsigned int index,
112  vtkTextureObject *texture,
113  unsigned int zslice=0);
114 
115  vtkTextureObject *GetColorBuffer(unsigned int index);
116  void RemoveColorBuffer(unsigned int index);
117  void RemoveAllColorBuffers();
118 
120 
121  void SetDepthBuffer(vtkTextureObject *depthTexture);
122  void RemoveDepthBuffer();
124 
126 
128  vtkSetMacro(DepthBufferNeeded,bool);
129  vtkGetMacro(DepthBufferNeeded,bool);
131 
133 
134  void SetNumberOfRenderTargets(unsigned int);
135  vtkGetMacro(NumberOfRenderTargets,unsigned int);
137 
141  unsigned int GetMaximumNumberOfActiveTargets();
142 
146  unsigned int GetMaximumNumberOfRenderTargets();
147 
149 
150  vtkGetVector2Macro(LastSize,int);
152 
154  static bool IsSupported(vtkRenderWindow *renWin);
155 
156 //BTX
157 protected:
159  void CheckFrameBufferStatus();
160 
162  void DisplayFrameBufferAttachments();
163 
165  void DisplayFrameBufferAttachment(unsigned int uattachment);
166 
168  void DisplayDrawBuffers();
169 
171  void DisplayReadBuffer();
172 
174  void DisplayBuffer(int value);
175 
178 
180 
183  unsigned int FBOIndex;
184  int PreviousFBOIndex; // -1: no previous FBO
185  unsigned int DepthBuffer;
186 
187  unsigned int NumberOfRenderTargets;
188  // TODO: add support for stencil buffer.
189 
190  int LastSize[2];
191 
192  void CreateFBO();
193  void DestroyFBO();
194  void Create(int width,
195  int height);
196  void CreateBuffers(int width,
197  int height);
198  void CreateColorBuffers(int width,
199  int height,
200  bool shaderSupportsTextureInt);
201  void Destroy();
202  void DestroyBuffers();
203  void DestroyColorBuffers();
204  void ActivateBuffers();
205 
207  bool LoadRequiredExtensions(vtkOpenGLExtensionManager *manager);
208 
209  vtkstd::vector<unsigned int> UserZSlices;
210  vtkstd::vector<vtkSmartPointer<vtkTextureObject> > UserColorBuffers;
211  vtkstd::vector<vtkSmartPointer<vtkTextureObject> > ColorBuffers;
212  vtkstd::vector<unsigned int> ActiveBuffers;
215 private:
216  vtkFrameBufferObject(const vtkFrameBufferObject&); // Not implemented.
217  void operator=(const vtkFrameBufferObject&); // Not implemented.
218 //ETX
219 };
220 
221 #endif
abstract base class for most VTK objects
Definition: vtkObject.h:60
unsigned int NumberOfRenderTargets
void SetActiveBuffer(unsigned int index)
vtkWeakPointer< vtkRenderWindow > Context
virtual void PrintSelf(ostream &os, vtkIndent indent)
a simple class to control print indentation
Definition: vtkIndent.h:37
vtkSmartPointer< vtkTextureObject > UserDepthBuffer
vtkstd::vector< unsigned int > ActiveBuffers
Interface class for querying and using OpenGL extensions.
vtkstd::vector< unsigned int > UserZSlices
vtkstd::vector< vtkSmartPointer< vtkTextureObject > > UserColorBuffers
internal class which encapsulates OpenGL frame buffer object. Not to be used directly.
#define VTK_RENDERING_EXPORT
abstracts an OpenGL texture object.
create a window for renderers to draw into
vtkstd::vector< vtkSmartPointer< vtkTextureObject > > ColorBuffers
static vtkObject * New()