Public Member Functions | |
virtual void | attachRenderBuffer (GLuint buffId, GLenum attachment=GL_DEPTH_ATTACHMENT_EXT) |
Bind a render buffer to the "attachment" point of this FBO. | |
virtual void | attachRenderBuffers (int numBuffers, GLuint buffId[], GLenum attachment[]=NULL) |
virtual void | attachTexture (GLenum texTarget, GLuint texId, GLenum attachment=GL_COLOR_ATTACHMENT0_EXT, int mipLevel=0, int zSlice=0) |
Bind a texture to the "attachment" point of this FBO. | |
virtual void | attachTextures (int numTextures, GLenum texTarget[], GLuint texId[], GLenum attachment[]=NULL, int mipLevel[]=NULL, int zSlice[]=NULL) |
void | bind () |
Bind this FBO as current render target. | |
GLint | getAttachedCubeFace (GLenum attachment) |
Which cube face is currently attached to "attachment?". | |
GLuint | getAttachedId (GLenum attachment) |
GLint | getAttachedMipLevel (GLenum attachment) |
Which mipmap level is currently attached to "attachement?". | |
GLenum | getAttachedType (GLenum attachment) |
Is attached type GL_RENDERBUFFER_EXT or GL_TEXTURE? | |
GLint | getAttachedZSlice (GLenum attachment) |
Which z-slice is currently attached to "attachment?". | |
GlFbo () | |
Constructor. | |
bool | isValid (std::ostream &ostr=std::cerr) |
bool | isValid (std::ostream &ostr=std::cerr) |
void | unattach (GLenum attachment) |
Free any resource bound to the "attachment" point of this FBO. | |
void | unattachAll () |
Free any resources bound to any attachment points of this FBO. | |
virtual | ~GlFbo () |
Deconstructor. | |
Static Public Member Functions | |
static bool | checkGlErrors (const char *codeLocation=NULL) |
END : Accessors. | |
static void | disable () |
static int | getMaxColorAttachments () |
Return number of color attachments permitted. | |
Protected Member Functions | |
void | _framebufferTextureND (GLenum attachment, GLenum texTarget, GLuint texId, int mipLevel, int zSlice) |
void | _guardedBind () |
END : Static methods global to all FBOs. | |
void | _guardedUnbind () |
Static Protected Member Functions | |
static GLuint | _generateFboId () |
for details.
A framebuffer object (FBO) is conceptually a structure containing pointers to GPU memory. The memory pointed to is either an OpenGL texture or an OpenGL RenderBuffer. FBOs can be used to render to one or more textures, share depth buffers between multiple sets of color buffers/textures and are a complete replacement for pbuffers.
Performance Notes: 1) It is more efficient (but not required) to call bind() on an FBO before making multiple method calls. For example:
GlFbo fbo; fbo.Bind(); fbo.attachTexture(GL_TEXTURE_2D, texId0, GL_COLOR_ATTACHMENT0_EXT); fbo.attachTexture(GL_TEXTURE_2D, texId1, GL_COLOR_ATTACHMENT1_EXT); fbo.isValid();
To provide a complete encapsulation, the following usage pattern works correctly but is less efficient:
GlFbo fbo; NOTE : No bind() call fbo.attachTexture(GL_TEXTURE_2D, texId0, GL_COLOR_ATTACHMENT0_EXT); fbo.attachTexture(GL_TEXTURE_2D, texId1, GL_COLOR_ATTACHMENT1_EXT); fbo.isValid();
The first usage pattern binds the FBO only once, whereas the second usage binds/unbinds the FBO for each method call.
2) Use GlFbo::disable() sparingly. We have intentionally left out an "Unbind()" method because it is largely unnecessary and encourages rendundant Bind/Unbind coding. Binding an FBO is usually much faster than enabling/disabling a pbuffer, but is still a costly operation. When switching between multiple FBOs and a visible OpenGL framebuffer, the following usage pattern is recommended:
GlFbo fbo1, fbo2; fbo1.Bind(); ... Render ... NOTE : No Unbind/Disable here...
fbo2.Bind(); ... Render ...
Disable FBO rendering and return to visible window OpenGL framebuffer. GlFbo::disable();
opentl::cvprocess::GlFbo::GlFbo | ( | ) |
Constructor.
virtual opentl::cvprocess::GlFbo::~GlFbo | ( | ) | [virtual] |
Deconstructor.
void opentl::cvprocess::GlFbo::_framebufferTextureND | ( | GLenum | attachment, | |
GLenum | texTarget, | |||
GLuint | texId, | |||
int | mipLevel, | |||
int | zSlice | |||
) | [protected] |
static GLuint opentl::cvprocess::GlFbo::_generateFboId | ( | ) | [static, protected] |
void opentl::cvprocess::GlFbo::_guardedBind | ( | ) | [protected] |
END : Static methods global to all FBOs.
void opentl::cvprocess::GlFbo::_guardedUnbind | ( | ) | [protected] |
virtual void opentl::cvprocess::GlFbo::attachRenderBuffer | ( | GLuint | buffId, | |
GLenum | attachment = GL_DEPTH_ATTACHMENT_EXT | |||
) | [virtual] |
Bind a render buffer to the "attachment" point of this FBO.
virtual void opentl::cvprocess::GlFbo::attachRenderBuffers | ( | int | numBuffers, | |
GLuint | buffId[], | |||
GLenum | attachment[] = NULL | |||
) | [virtual] |
Bind an array of render buffers to corresponding "attachment" points of this FBO.
virtual void opentl::cvprocess::GlFbo::attachTexture | ( | GLenum | texTarget, | |
GLuint | texId, | |||
GLenum | attachment = GL_COLOR_ATTACHMENT0_EXT , |
|||
int | mipLevel = 0 , |
|||
int | zSlice = 0 | |||
) | [virtual] |
Bind a texture to the "attachment" point of this FBO.
virtual void opentl::cvprocess::GlFbo::attachTextures | ( | int | numTextures, | |
GLenum | texTarget[], | |||
GLuint | texId[], | |||
GLenum | attachment[] = NULL , |
|||
int | mipLevel[] = NULL , |
|||
int | zSlice[] = NULL | |||
) | [virtual] |
Bind an array of textures to multiple "attachment" points of this FBO
void opentl::cvprocess::GlFbo::bind | ( | ) |
Bind this FBO as current render target.
static bool opentl::cvprocess::GlFbo::checkGlErrors | ( | const char * | codeLocation = NULL |
) | [static] |
END : Accessors.
BEGIN : Static methods global to all FBOs Check for OpenGL execution errors. ATTENTION: This functions checks for errors in DEBUG MODE ONLY!!!!
codeLocation | Optional, user defineable string to identify location in code. |
static void opentl::cvprocess::GlFbo::disable | ( | ) | [static] |
Disable all FBO rendering and return to traditional, windowing-system controlled framebuffer NOTE: This is NOT an "unbind" for this specific FBO, but rather disables all FBO rendering. This call is intentionally "static" and named "Disable" instead of "Unbind" for this reason. The motivation for this strange semantic is performance. Providing "Unbind" would likely lead to a large number of unnecessary FBO enablings/disabling.
GLint opentl::cvprocess::GlFbo::getAttachedCubeFace | ( | GLenum | attachment | ) |
Which cube face is currently attached to "attachment?".
GLuint opentl::cvprocess::GlFbo::getAttachedId | ( | GLenum | attachment | ) |
What is the Id of Renderbuffer/texture currently attached to "attachement?"
GLint opentl::cvprocess::GlFbo::getAttachedMipLevel | ( | GLenum | attachment | ) |
Which mipmap level is currently attached to "attachement?".
GLenum opentl::cvprocess::GlFbo::getAttachedType | ( | GLenum | attachment | ) |
Is attached type GL_RENDERBUFFER_EXT or GL_TEXTURE?
BEGIN : Accessors
GLint opentl::cvprocess::GlFbo::getAttachedZSlice | ( | GLenum | attachment | ) |
Which z-slice is currently attached to "attachment?".
static int opentl::cvprocess::GlFbo::getMaxColorAttachments | ( | ) | [static] |
Return number of color attachments permitted.
bool opentl::cvprocess::GlFbo::isValid | ( | std::ostream & | ostr = std::cerr |
) | [inline] |
bool opentl::cvprocess::GlFbo::isValid | ( | std::ostream & | ostr = std::cerr |
) |
Is this FBO currently a valid render target?
NOTE : This function works correctly in debug build mode but always returns "true" if NDEBUG is is defined (optimized builds)
void opentl::cvprocess::GlFbo::unattach | ( | GLenum | attachment | ) |
Free any resource bound to the "attachment" point of this FBO.
void opentl::cvprocess::GlFbo::unattachAll | ( | ) |
Free any resources bound to any attachment points of this FBO.