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:
51  void PrintSelf(ostream& os, vtkIndent indent);
52 
54 
61  void SetContext(vtkRenderWindow *context);
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 
131  unsigned int index,
132  vtkTextureObject *texture,
133  unsigned int zslice=0);
134 
136  void RemoveColorBuffer(unsigned int index);
138 
140 
143  void SetDepthBuffer(vtkTextureObject *depthTexture);
146 
148 
152  vtkSetMacro(DepthBufferNeeded,bool);
153  vtkGetMacro(DepthBufferNeeded,bool);
155 
157 
164  void SetNumberOfRenderTargets(unsigned int);
165  vtkGetMacro(NumberOfRenderTargets,unsigned int);
167 
174 
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
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
224  int width,
225  int height,
226  unsigned int mode,
227  bool shaderSupportsTextureInt);
228 
229  // detach and delete our reference(s)
232 
233  // glDrawBuffers
235 
240 
244  void DisplayFrameBufferAttachment(unsigned int uattachment);
245 
250 
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
vtkFrameBufferObject
internal class which encapsulates OpenGL frame buffer object.
Definition: vtkFrameBufferObject.h:47
vtkFrameBufferObject::SetActiveBuffers
void SetActiveBuffers(int numbuffers, unsigned int indices[])
User provided color buffers are attached by index to color buffers.
vtkFrameBufferObject::ActiveBuffers
std::vector< unsigned int > ActiveBuffers
Definition: vtkFrameBufferObject.h:276
vtkFrameBufferObject::ColorBuffersDirty
bool ColorBuffersDirty
Definition: vtkFrameBufferObject.h:267
vtkFrameBufferObject::DepthBuffer
unsigned int DepthBuffer
Definition: vtkFrameBufferObject.h:270
vtkFrameBufferObject::DestroyColorBuffers
void DestroyColorBuffers()
vtkX3D::value
@ value
Definition: vtkX3D.h:220
vtkFrameBufferObject::DisplayBuffer
void DisplayBuffer(int value)
Display any buffer (convert value into string).
vtkFrameBufferObject::IsSupported
static bool IsSupported(vtkRenderWindow *renWin)
Returns if the context supports the required extensions.
vtkFrameBufferObject::CreateDepthBuffer
void CreateDepthBuffer(int width, int height, unsigned int mode)
vtkFrameBufferObject::CheckFrameBufferStatus
int CheckFrameBufferStatus(unsigned int mode)
Validate the current FBO configuration (attachments, formats, etc) prints detected errors to vtkError...
vtkFrameBufferObject::SetActiveBuffer
void SetActiveBuffer(unsigned int index)
Choose the buffers to render into.
Definition: vtkFrameBufferObject.h:105
vtkFrameBufferObject::CreateFBO
void CreateFBO()
vtkSmartPointer< vtkTextureObject >
vtkFrameBufferObject::DisplayReadBuffer
void DisplayReadBuffer()
Display the read buffer.
vtkFrameBufferObject::UnBind
void UnBind()
Restore the previous draw framebuffer if saved, else bind the default buffer.
vtkFrameBufferObject::RenderQuad
void RenderQuad(int minX, int maxX, int minY, int maxY)
Renders a quad at the given location with pixel coordinates.
vtkFrameBufferObject::RemoveColorBuffer
void RemoveColorBuffer(unsigned int index)
vtkFrameBufferObject::FBOIndex
unsigned int FBOIndex
Definition: vtkFrameBufferObject.h:268
vtkFrameBufferObject::SetContext
void SetContext(vtkRenderWindow *context)
Get/Set the context.
vtkFrameBufferObject::ColorBuffers
std::vector< vtkSmartPointer< vtkTextureObject > > ColorBuffers
Definition: vtkFrameBufferObject.h:275
vtkFrameBufferObjectBase
abstract interface to OpenGL FBOs
Definition: vtkFrameBufferObjectBase.h:33
vtkFrameBufferObject::DestroyFBO
void DestroyFBO()
vtkFrameBufferObject::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent)
Methods invoked by print to print information about the object including superclasses.
vtkFrameBufferObject::PreviousFBOIndex
int PreviousFBOIndex
Definition: vtkFrameBufferObject.h:269
vtkFrameBufferObject::LoadRequiredExtensions
static bool LoadRequiredExtensions(vtkRenderWindow *renWin)
Load all necessary extensions.
vtkFrameBufferObject::StartNonOrtho
bool StartNonOrtho(int width, int height, bool shaderSupportsTextureInt)
vtkFrameBufferObject::NumberOfRenderTargets
unsigned int NumberOfRenderTargets
Definition: vtkFrameBufferObject.h:271
vtkOpenGLExtensionManager
Interface class for querying and using OpenGL extensions.
vtkFrameBufferObject::Context
vtkWeakPointer< vtkRenderWindow > Context
Definition: vtkFrameBufferObject.h:264
vtkFrameBufferObject::DisplayFrameBufferAttachment
void DisplayFrameBufferAttachment(unsigned int uattachment)
Display a given attachment for the current framebuffer object.
vtkFrameBufferObject::Bind
void Bind()
Make the draw frame buffer active (uses FRAMEBUFFER).
vtkX3D::height
@ height
Definition: vtkX3D.h:254
vtkFrameBufferObject::Start
bool Start(int width, int height, bool shaderSupportsTextureInt)
User must take care that width/height match the dimensions of the user defined texture attachments.
vtkFrameBufferObject::UserDepthBuffer
vtkSmartPointer< vtkTextureObject > UserDepthBuffer
Definition: vtkFrameBufferObject.h:277
vtkFrameBufferObject::DepthBufferDirty
bool DepthBufferDirty
Definition: vtkFrameBufferObject.h:278
vtkFrameBufferObject::UserZSlices
std::vector< unsigned int > UserZSlices
Definition: vtkFrameBufferObject.h:273
vtkFrameBufferObject::DisplayFrameBufferAttachments
void DisplayFrameBufferAttachments()
Display all the attachments of the current framebuffer object.
vtkFrameBufferObject::GetContext
vtkRenderWindow * GetContext()
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:40
vtkTextureObject
abstracts an OpenGL texture object.
Definition: vtkTextureObject.h:44
vtkFrameBufferObject::SetColorBuffer
void SetColorBuffer(unsigned int index, vtkTextureObject *texture, unsigned int zslice=0)
Insert a color buffer into the list of available color buffers.
vtkFrameBufferObject::ActivateBuffers
void ActivateBuffers()
vtkFrameBufferObject::DestroyDepthBuffer
void DestroyDepthBuffer()
vtkFrameBufferObject::UserColorBuffers
std::vector< vtkSmartPointer< vtkTextureObject > > UserColorBuffers
Definition: vtkFrameBufferObject.h:274
vtkSmartPointer.h
vtkWeakPointer.h
vtkFrameBufferObject::GetMaximumNumberOfRenderTargets
unsigned int GetMaximumNumberOfRenderTargets()
Returns the maximum number of render targets available.
vtkFrameBufferObject::DepthBufferNeeded
bool DepthBufferNeeded
Definition: vtkFrameBufferObject.h:266
vtkFrameBufferObject::GetColorBuffer
vtkTextureObject * GetColorBuffer(unsigned int index)
vtkFrameBufferObject::RemoveAllColorBuffers
void RemoveAllColorBuffers()
vtkFrameBufferObject::~vtkFrameBufferObject
~vtkFrameBufferObject()
vtkFrameBufferObject::DisplayDrawBuffers
void DisplayDrawBuffers()
Display the draw buffers.
vtkFrameBufferObject::GetMaximumNumberOfActiveTargets
unsigned int GetMaximumNumberOfActiveTargets()
Returns the maximum number of targets that can be rendered to at one time.
vtkSetMacro
vtkSetMacro(IgnoreDriverBugs, bool)
Updates the extensions string.
vtkFrameBufferObject::SetNumberOfRenderTargets
void SetNumberOfRenderTargets(unsigned int)
Set/Get the number of render targets to render into at once.
vtkFrameBufferObjectBase.h
vtkFrameBufferObject::New
static vtkFrameBufferObject * New()
vtkFrameBufferObject::SetDepthBuffer
void SetDepthBuffer(vtkTextureObject *depthTexture)
Set the texture to use as depth buffer.
vtkFrameBufferObject::CreateColorBuffers
void CreateColorBuffers(int width, int height, unsigned int mode, bool shaderSupportsTextureInt)
vtkX3D::mode
@ mode
Definition: vtkX3D.h:247
vtkOpenGLRenderWindow
OpenGL rendering window.
Definition: vtkOpenGLRenderWindow.h:42
vtkRenderWindow
create a window for renderers to draw into
Definition: vtkRenderWindow.h:87
vtkFrameBufferObject::RemoveDepthBuffer
void RemoveDepthBuffer()
vtkX3D::index
@ index
Definition: vtkX3D.h:246
vtkPixelBufferObject
abstracts an OpenGL pixel buffer object.
Definition: vtkPixelBufferObject.h:44
vtkWeakPointer< vtkRenderWindow >
vtkRenderbuffer
Storage for FBO's.
Definition: vtkRenderbuffer.h:33
vtkFrameBufferObject::vtkFrameBufferObject
vtkFrameBufferObject()