Cinder  0.8.6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
cinder::gl::Fbo Class Reference

Represents an OpenGL Framebuffer Object. //! Represents an instance of a font at a point size. Implicitly shared object. More...

#include <Fbo.h>

Classes

struct  Format
 
struct  Obj
 

Public Member Functions

 Fbo ()
 Creates a NULL FBO. More...
 
 Fbo (int width, int height, Format format=Format())
 Creates an FBO width pixels wide and height pixels high, using Fbo::Format format. More...
 
 Fbo (int width, int height, bool alpha, bool color=true, bool depth=true)
 Creates an FBO width pixels wide and height pixels high, with an optional alpha channel, color buffer and depth buffer. More...
 
int getWidth () const
 Returns the width of the FBO in pixels. More...
 
int getHeight () const
 Returns the height of the FBO in pixels. More...
 
Vec2i getSize () const
 Returns the size of the FBO in pixels. More...
 
Area getBounds () const
 Returns the bounding area of the FBO in pixels. More...
 
float getAspectRatio () const
 Returns the aspect ratio of the FBO. More...
 
const FormatgetFormat () const
 Returns the Fbo::Format of this FBO. More...
 
GLenum getTarget () const
 Returns the texture target for this FBO. Typically GL_TEXTURE_2D or GL_TEXTURE_RECTANGLE_ARB. More...
 
TexturegetTexture (int attachment=0)
 Returns a reference to the color texture of the FBO. attachment specifies which attachment in the case of multiple color buffers. More...
 
TexturegetDepthTexture ()
 Returns a reference to the depth texture of the FBO. More...
 
void bindTexture (int textureUnit=0, int attachment=0)
 Binds the color texture associated with an Fbo to its target. Optionally binds to a multitexturing unit when textureUnit is non-zero. Optionally binds to a multitexturing unit when textureUnit is non-zero. attachment specifies which color buffer in the case of multiple attachments. More...
 
void unbindTexture ()
 Unbinds the texture associated with an Fbo's target. More...
 
void bindDepthTexture (int textureUnit=0)
 Binds the depth texture associated with an Fbo to its target. More...
 
void bindFramebuffer ()
 Binds the Fbo as the currently active framebuffer, meaning it will receive the results of all subsequent rendering until it is unbound. More...
 
GLuint getId () const
 Returns the ID of the framebuffer itself. For antialiased FBOs this is the ID of the output multisampled FBO. More...
 
GLuint getResolveId () const
 For antialiased FBOs this returns the ID of the mirror FBO designed for reading, where the multisampled render buffers are resolved to. For non-antialised, this is the equivalent to getId() More...
 
void blitTo (Fbo dst, const Area &srcArea, const Area &dstArea, GLenum filter=GL_NEAREST, GLbitfield mask=GL_COLOR_BUFFER_BIT) const
 Copies to FBO dst from srcArea to dstArea using filter filter. mask allows specification of color (GL_COLOR_BUFFER_BIT) and/or depth(GL_DEPTH_BUFFER_BIT). Calls glBlitFramebufferEXT() and is subject to its constraints and coordinate system. More...
 
void blitToScreen (const Area &srcArea, const Area &dstArea, GLenum filter=GL_NEAREST, GLbitfield mask=GL_COLOR_BUFFER_BIT) const
 Copies to the screen from Area srcArea to dstArea using filter filter. mask allows specification of color (GL_COLOR_BUFFER_BIT) and/or depth(GL_DEPTH_BUFFER_BIT). Calls glBlitFramebufferEXT() and is subject to its constraints and coordinate system. More...
 
void blitFromScreen (const Area &srcArea, const Area &dstArea, GLenum filter=GL_NEAREST, GLbitfield mask=GL_COLOR_BUFFER_BIT)
 Copies from the screen from Area srcArea to dstArea using filter filter. mask allows specification of color (GL_COLOR_BUFFER_BIT) and/or depth(GL_DEPTH_BUFFER_BIT). Calls glBlitFramebufferEXT() and is subject to its constraints and coordinate system. More...
 

Static Public Member Functions

static void unbindFramebuffer ()
 Unbinds the Fbo as the currently active framebuffer, restoring the primary context as the target for all subsequent rendering. More...
 
static GLint getMaxSamples ()
 Returns the maximum number of samples the graphics card is capable of using per pixel in MSAA for an Fbo. More...
 
static GLint getMaxAttachments ()
 Returns the maximum number of color attachments the graphics card is capable of using for an Fbo. More...
 

Protected Member Functions

void init ()
 
bool initMultisample (bool csaa)
 
void resolveTextures () const
 
void updateMipmaps (bool bindFirst, int attachment) const
 
bool checkStatus (class FboExceptionInvalidSpecification *resultExc)
 

Protected Attributes

std::shared_ptr< ObjmObj
 

Static Protected Attributes

static GLint sMaxSamples = -1
 
static GLint sMaxAttachments = -1
 
typedef std::shared_ptr< Obj >
Fbo::* 
unspecified_bool_type
 Emulates shared_ptr-like behavior. More...
 
 operator unspecified_bool_type () const
 Emulates shared_ptr-like behavior. More...
 
void reset ()
 Emulates shared_ptr-like behavior. More...
 

Detailed Description

Represents an OpenGL Framebuffer Object. //! Represents an instance of a font at a point size. Implicitly shared object.

FBOs are used for doing off-screen rendering, including rendering to a texture. An FBO can capture draw commands that would normally go to the screen, and can be used to implement a large variety of techniques, particularly post-processing effects like blurs, depth-of-field and the like. FBOs are formally specified in the extension GL_EXT_framebuffer_object.

See also
Guide to Framebuffer Objects (FBOs)

Member Typedef Documentation

typedef std::shared_ptr<Obj> Fbo::* cinder::gl::Fbo::unspecified_bool_type

Emulates shared_ptr-like behavior.

Constructor & Destructor Documentation

cinder::gl::Fbo::Fbo ( )

Creates a NULL FBO.

cinder::gl::Fbo::Fbo ( int  width,
int  height,
Format  format = Format() 
)

Creates an FBO width pixels wide and height pixels high, using Fbo::Format format.

cinder::gl::Fbo::Fbo ( int  width,
int  height,
bool  alpha,
bool  color = true,
bool  depth = true 
)

Creates an FBO width pixels wide and height pixels high, with an optional alpha channel, color buffer and depth buffer.

Member Function Documentation

int cinder::gl::Fbo::getWidth ( ) const

Returns the width of the FBO in pixels.

int cinder::gl::Fbo::getHeight ( ) const

Returns the height of the FBO in pixels.

Vec2i cinder::gl::Fbo::getSize ( ) const

Returns the size of the FBO in pixels.

Area cinder::gl::Fbo::getBounds ( ) const

Returns the bounding area of the FBO in pixels.

float cinder::gl::Fbo::getAspectRatio ( ) const

Returns the aspect ratio of the FBO.

const Format& cinder::gl::Fbo::getFormat ( ) const

Returns the Fbo::Format of this FBO.

GLenum cinder::gl::Fbo::getTarget ( ) const

Returns the texture target for this FBO. Typically GL_TEXTURE_2D or GL_TEXTURE_RECTANGLE_ARB.

Texture & cinder::gl::Fbo::getTexture ( int  attachment = 0)

Returns a reference to the color texture of the FBO. attachment specifies which attachment in the case of multiple color buffers.

Texture & cinder::gl::Fbo::getDepthTexture ( )

Returns a reference to the depth texture of the FBO.

void cinder::gl::Fbo::bindTexture ( int  textureUnit = 0,
int  attachment = 0 
)

Binds the color texture associated with an Fbo to its target. Optionally binds to a multitexturing unit when textureUnit is non-zero. Optionally binds to a multitexturing unit when textureUnit is non-zero. attachment specifies which color buffer in the case of multiple attachments.

void cinder::gl::Fbo::unbindTexture ( )

Unbinds the texture associated with an Fbo's target.

void cinder::gl::Fbo::bindDepthTexture ( int  textureUnit = 0)

Binds the depth texture associated with an Fbo to its target.

void cinder::gl::Fbo::bindFramebuffer ( )

Binds the Fbo as the currently active framebuffer, meaning it will receive the results of all subsequent rendering until it is unbound.

void cinder::gl::Fbo::unbindFramebuffer ( )
static

Unbinds the Fbo as the currently active framebuffer, restoring the primary context as the target for all subsequent rendering.

GLuint cinder::gl::Fbo::getId ( ) const

Returns the ID of the framebuffer itself. For antialiased FBOs this is the ID of the output multisampled FBO.

GLuint cinder::gl::Fbo::getResolveId ( ) const

For antialiased FBOs this returns the ID of the mirror FBO designed for reading, where the multisampled render buffers are resolved to. For non-antialised, this is the equivalent to getId()

void cinder::gl::Fbo::blitTo ( Fbo  dst,
const Area srcArea,
const Area dstArea,
GLenum  filter = GL_NEAREST,
GLbitfield  mask = GL_COLOR_BUFFER_BIT 
) const

Copies to FBO dst from srcArea to dstArea using filter filter. mask allows specification of color (GL_COLOR_BUFFER_BIT) and/or depth(GL_DEPTH_BUFFER_BIT). Calls glBlitFramebufferEXT() and is subject to its constraints and coordinate system.

void cinder::gl::Fbo::blitToScreen ( const Area srcArea,
const Area dstArea,
GLenum  filter = GL_NEAREST,
GLbitfield  mask = GL_COLOR_BUFFER_BIT 
) const

Copies to the screen from Area srcArea to dstArea using filter filter. mask allows specification of color (GL_COLOR_BUFFER_BIT) and/or depth(GL_DEPTH_BUFFER_BIT). Calls glBlitFramebufferEXT() and is subject to its constraints and coordinate system.

void cinder::gl::Fbo::blitFromScreen ( const Area srcArea,
const Area dstArea,
GLenum  filter = GL_NEAREST,
GLbitfield  mask = GL_COLOR_BUFFER_BIT 
)

Copies from the screen from Area srcArea to dstArea using filter filter. mask allows specification of color (GL_COLOR_BUFFER_BIT) and/or depth(GL_DEPTH_BUFFER_BIT). Calls glBlitFramebufferEXT() and is subject to its constraints and coordinate system.

GLint cinder::gl::Fbo::getMaxSamples ( )
static

Returns the maximum number of samples the graphics card is capable of using per pixel in MSAA for an Fbo.

GLint cinder::gl::Fbo::getMaxAttachments ( )
static

Returns the maximum number of color attachments the graphics card is capable of using for an Fbo.

void cinder::gl::Fbo::init ( )
protected
bool cinder::gl::Fbo::initMultisample ( bool  csaa)
protected
void cinder::gl::Fbo::resolveTextures ( ) const
protected
void cinder::gl::Fbo::updateMipmaps ( bool  bindFirst,
int  attachment 
) const
protected
bool cinder::gl::Fbo::checkStatus ( class FboExceptionInvalidSpecification resultExc)
protected
cinder::gl::Fbo::operator unspecified_bool_type ( ) const

Emulates shared_ptr-like behavior.

void cinder::gl::Fbo::reset ( )

Emulates shared_ptr-like behavior.

Member Data Documentation

std::shared_ptr<Obj> cinder::gl::Fbo::mObj
protected
GLint cinder::gl::Fbo::sMaxSamples = -1
staticprotected
GLint cinder::gl::Fbo::sMaxAttachments = -1
staticprotected

The documentation for this class was generated from the following files: