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
39class vtkRenderWindow;
41class vtkRenderbuffer;
45
46class VTKRENDERINGOPENGL_EXPORT vtkFrameBufferObject : public vtkFrameBufferObjectBase
47{
48public:
51 void PrintSelf(ostream& os, vtkIndent indent);
52
54
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
201protected:
205 static
207
208 // gen buffer (occurs when context is set)
209 void CreateFBO();
210
211 // delete buffer (occurs during destruction or context swicth)
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
260
263
265
268 unsigned int FBOIndex;
270 unsigned int DepthBuffer;
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
280private:
281 vtkFrameBufferObject(const vtkFrameBufferObject&) VTK_DELETE_FUNCTION;
282 void operator=(const vtkFrameBufferObject&) VTK_DELETE_FUNCTION;
283
284};
285
286#endif
abstract interface to OpenGL FBOs
internal class which encapsulates OpenGL frame buffer object.
bool StartNonOrtho(int width, int height, bool shaderSupportsTextureInt)
unsigned int GetMaximumNumberOfRenderTargets()
Returns the maximum number of render targets available.
void PrintSelf(ostream &os, vtkIndent indent)
Methods invoked by print to print information about the object including superclasses.
void DisplayFrameBufferAttachments()
Display all the attachments of the current framebuffer object.
vtkRenderWindow * GetContext()
void SetColorBuffer(unsigned int index, vtkTextureObject *texture, unsigned int zslice=0)
Insert a color buffer into the list of available color buffers.
bool Start(int width, int height, bool shaderSupportsTextureInt)
User must take care that width/height match the dimensions of the user defined texture attachments.
void SetNumberOfRenderTargets(unsigned int)
Set/Get the number of render targets to render into at once.
void DisplayBuffer(int value)
Display any buffer (convert value into string).
void RemoveColorBuffer(unsigned int index)
static bool IsSupported(vtkRenderWindow *renWin)
Returns if the context supports the required extensions.
static vtkFrameBufferObject * New()
void UnBind()
Restore the previous draw framebuffer if saved, else bind the default buffer.
unsigned int GetMaximumNumberOfActiveTargets()
Returns the maximum number of targets that can be rendered to at one time.
void DisplayReadBuffer()
Display the read buffer.
void CreateColorBuffers(int width, int height, unsigned int mode, bool shaderSupportsTextureInt)
unsigned int NumberOfRenderTargets
static bool LoadRequiredExtensions(vtkRenderWindow *renWin)
Load all necessary extensions.
void SetActiveBuffer(unsigned int index)
Choose the buffers to render into.
void SetActiveBuffers(int numbuffers, unsigned int indices[])
User provided color buffers are attached by index to color buffers.
std::vector< vtkSmartPointer< vtkTextureObject > > ColorBuffers
std::vector< vtkSmartPointer< vtkTextureObject > > UserColorBuffers
void SetContext(vtkRenderWindow *context)
Get/Set the context.
void DisplayFrameBufferAttachment(unsigned int uattachment)
Display a given attachment for the current framebuffer object.
int CheckFrameBufferStatus(unsigned int mode)
Validate the current FBO configuration (attachments, formats, etc) prints detected errors to vtkError...
std::vector< unsigned int > ActiveBuffers
std::vector< unsigned int > UserZSlices
vtkWeakPointer< vtkRenderWindow > Context
void RenderQuad(int minX, int maxX, int minY, int maxY)
Renders a quad at the given location with pixel coordinates.
void SetDepthBuffer(vtkTextureObject *depthTexture)
Set the texture to use as depth buffer.
vtkSmartPointer< vtkTextureObject > UserDepthBuffer
void Bind()
Make the draw frame buffer active (uses FRAMEBUFFER).
void CreateDepthBuffer(int width, int height, unsigned int mode)
vtkTextureObject * GetColorBuffer(unsigned int index)
void DisplayDrawBuffers()
Display the draw buffers.
a simple class to control print indentation
Definition: vtkIndent.h:40
Interface class for querying and using OpenGL extensions.
OpenGL rendering window.
abstracts an OpenGL pixel buffer object.
create a window for renderers to draw into
Storage for FBO's.
abstracts an OpenGL texture object.
@ mode
Definition: vtkX3D.h:247
@ value
Definition: vtkX3D.h:220
@ height
Definition: vtkX3D.h:254
@ index
Definition: vtkX3D.h:246
vtkSetMacro(IgnoreDriverBugs, bool)
Updates the extensions string.