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 =========================================================================*/
28 #ifndef vtkFrameBufferObject_h
29 #define vtkFrameBufferObject_h
30 
31 #include "vtkObject.h"
32 #include "vtkRenderingOpenGLModule.h" // For export macro
33 #include "vtkSmartPointer.h" // needed for vtkSmartPointer.
34 #include "vtkWeakPointer.h" // needed for vtkWeakPointer.
35 //BTX
36 #include <vector> // for the lists of logical buffers.
37 //ETX
38 
39 class vtkRenderWindow;
40 class vtkTextureObject;
41 class vtkRenderbuffer;
45 
47 {
48 public:
49  static vtkFrameBufferObject* New();
51  void PrintSelf(ostream& os, vtkIndent indent);
52 
54 
58  void SetContext(vtkRenderWindow *context);
59  vtkRenderWindow *GetContext();
61 
63 
69  bool Start(int width, int height, bool shaderSupportsTextureInt);
70  bool StartNonOrtho(int width, int height, bool shaderSupportsTextureInt);
72 
78  void RenderQuad(int minX, int maxX, int minY, int maxY);
79 
81  void Bind();
82 
85  void UnBind();
86 
88 
89  void SetActiveBuffer(unsigned int index)
90  {
91  this->SetActiveBuffers(1, &index);
92  }
94 
99  void SetActiveBuffers(int numbuffers, unsigned int indices[]);
100 
102 
110  void SetColorBuffer(
111  unsigned int index,
112  vtkTextureObject *texture,
113  unsigned int zslice=0);
115 
116  vtkTextureObject *GetColorBuffer(unsigned int index);
117  void RemoveColorBuffer(unsigned int index);
118  void RemoveAllColorBuffers();
119 
121 
122  void SetDepthBuffer(vtkTextureObject *depthTexture);
123  void RemoveDepthBuffer();
125 
127 
129  vtkSetMacro(DepthBufferNeeded,bool);
130  vtkGetMacro(DepthBufferNeeded,bool);
132 
134 
139  void SetNumberOfRenderTargets(unsigned int);
140  vtkGetMacro(NumberOfRenderTargets,unsigned int);
142 
146  unsigned int GetMaximumNumberOfActiveTargets();
147 
151  unsigned int GetMaximumNumberOfRenderTargets();
152 
154 
155  vtkGetVector2Macro(LastSize,int);
157 
160  static bool IsSupported(vtkRenderWindow *renWin);
161 
164  int CheckFrameBufferStatus(unsigned int mode);
165 
166 //BTX
167 protected:
169 
170  static
171  bool LoadRequiredExtensions(vtkRenderWindow *renWin);
173 
174  // gen buffer (occurs when context is set)
175  void CreateFBO();
176 
177  // delete buffer (occurs during destruction or context swicth)
178  void DestroyFBO();
179 
180  // create texture or renderbuffer and attach
181  // if user provided a texture just use that
182  // mode specifies DRAW or READ
183  void CreateDepthBuffer(int width, int height, unsigned int mode);
184 
185  // create textures for each target and attach
186  // if user provided textures use those, if the user
187  // provides any then they need to provide all
188  // mode specifies DRAW or READ
189  void CreateColorBuffers(
190  int width,
191  int height,
192  unsigned int mode,
193  bool shaderSupportsTextureInt);
194 
195  // detach and delete our reference(s)
196  void DestroyDepthBuffer();
197  void DestroyColorBuffers();
198 
199  // glDrawBuffers
200  void ActivateBuffers();
201 
203  void DisplayFrameBufferAttachments();
204 
206  void DisplayFrameBufferAttachment(unsigned int uattachment);
207 
209  void DisplayDrawBuffers();
210 
212  void DisplayReadBuffer();
213 
215  void DisplayBuffer(int value);
216 
219 
221 
224  unsigned int FBOIndex;
226  unsigned int DepthBuffer;
227  unsigned int NumberOfRenderTargets;
228  int LastSize[2];
229  std::vector<unsigned int> UserZSlices;
230  std::vector<vtkSmartPointer<vtkTextureObject> > UserColorBuffers;
231  std::vector<vtkSmartPointer<vtkTextureObject> > ColorBuffers;
232  std::vector<unsigned int> ActiveBuffers;
235 
236 private:
237  vtkFrameBufferObject(const vtkFrameBufferObject&); // Not implemented.
238  void operator=(const vtkFrameBufferObject&); // Not implemented.
239 //ETX
240 };
241 
242 #endif
OpenGL rendering window.
abstract base class for most VTK objects
Definition: vtkObject.h:61
std::vector< unsigned int > ActiveBuffers
unsigned int NumberOfRenderTargets
void SetActiveBuffer(unsigned int index)
vtkWeakPointer< vtkRenderWindow > Context
std::vector< vtkSmartPointer< vtkTextureObject > > ColorBuffers
std::vector< vtkSmartPointer< vtkTextureObject > > UserColorBuffers
virtual void PrintSelf(ostream &os, vtkIndent indent)
a simple class to control print indentation
Definition: vtkIndent.h:38
vtkSmartPointer< vtkTextureObject > UserDepthBuffer
std::vector< unsigned int > UserZSlices
#define VTKRENDERINGOPENGL_EXPORT
abstracts an OpenGL pixel buffer object.
Interface class for querying and using OpenGL extensions.
internal class which encapsulates OpenGL frame buffer object. Not to be used directly.
abstracts an OpenGL texture object.
create a window for renderers to draw into
Storage for FBO's.
static vtkObject * New()