Cinder  0.9.1
Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | Friends | List of all members
cinder::gl::Fbo Class Reference

#include <Fbo.h>

Inherits enable_shared_from_this< Fbo >.

Inherited by cinder::gl::FboCubeMap.

Classes

struct  Format
 

Public Member Functions

 ~Fbo ()
 
int getWidth () const
 
int getHeight () const
 
ivec2 getSize () const
 
Area getBounds () const
 
float getAspectRatio () const
 
const FormatgetFormat () const
 
Format getFormat ()
 
Texture2dRef getColorTexture ()
 
Texture2dRef getDepthTexture ()
 
Texture2dRef getTexture2d (GLenum attachment)
 
TextureBaseRef getTextureBase (GLenum attachment)
 
void bindTexture (int textureUnit=0, GLenum attachment=GL_COLOR_ATTACHMENT0)
 
void unbindTexture (int textureUnit=0, GLenum attachment=GL_COLOR_ATTACHMENT0)
 
void bindFramebuffer (GLenum target=GL_FRAMEBUFFER)
 
void resolveTextures () const
 
GLuint getId () const
 
GLuint getMultisampleId () const
 
GLuint getResolveId () const
 
void markAsDirty ()
 
void blitTo (const FboRef &dst, const Area &srcArea, const Area &dstArea, GLenum filter=GL_NEAREST, GLbitfield mask=GL_COLOR_BUFFER_BIT) const
 
void blitToScreen (const Area &srcArea, const Area &dstArea, GLenum filter=GL_NEAREST, GLbitfield mask=GL_COLOR_BUFFER_BIT) const
 
void blitFromScreen (const Area &srcArea, const Area &dstArea, GLenum filter=GL_NEAREST, GLbitfield mask=GL_COLOR_BUFFER_BIT)
 
const std::string & getLabel () const
 
void setLabel (const std::string &label)
 
Surface8u readPixels8u (const Area &area, GLenum attachment=GL_COLOR_ATTACHMENT0) const
 

Static Public Member Functions

static FboRef create (int width, int height, const Format &format=Format())
 
static FboRef create (int width, int height, bool alpha, bool depth=true, bool stencil=false)
 
static void unbindFramebuffer ()
 
static GLint getMaxSamples ()
 
static GLint getMaxAttachments ()
 

Protected Member Functions

 Fbo (int width, int height, const Format &format)
 
void init ()
 
void initMultisamplingSettings (bool *useMsaa, bool *useCsaa, Format *format)
 
void prepareAttachments (const Format &format, bool multisampling)
 
void attachAttachments ()
 
void initMultisample (const Format &format)
 
void updateMipmaps (GLenum attachment) const
 
bool checkStatus (class FboExceptionInvalidSpecification *resultExc)
 
void setDrawBuffers (GLuint fbId, const std::map< GLenum, RenderbufferRef > &attachmentsBuffer, const std::map< GLenum, TextureBaseRef > &attachmentsTexture)
 

Protected Attributes

int mWidth
 
int mHeight
 
Format mFormat
 
GLuint mId
 
GLuint mMultisampleFramebufferId
 
std::map< GLenum, RenderbufferRefmAttachmentsBuffer
 
std::map< GLenum, RenderbufferRefmAttachmentsMultisampleBuffer
 
std::map< GLenum, TextureBaseRefmAttachmentsTexture
 
std::string mLabel
 
bool mNeedsResolve
 
bool mNeedsMipmapUpdate
 

Static Protected Attributes

static GLint sMaxSamples = -1
 
static GLint sMaxAttachments = -1
 

Friends

std::ostream & operator<< (std::ostream &os, const Fbo &rhs)
 

Detailed Description

Represents an OpenGL Framebuffer Object.

Constructor & Destructor Documentation

cinder::gl::Fbo::~Fbo ( )
cinder::gl::Fbo::Fbo ( int  width,
int  height,
const Format format 
)
protected

Member Function Documentation

FboRef cinder::gl::Fbo::create ( int  width,
int  height,
const Format format = Format() 
)
static

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

FboRef cinder::gl::Fbo::create ( int  width,
int  height,
bool  alpha,
bool  depth = true,
bool  stencil = false 
)
static

Creates an FBO width pixels wide and height pixels high, a color texture (with optional alpha channel), and optionally a depth buffer and stencil buffer.

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.

ivec2 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.

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

Returns the Fbo::Format of this FBO.

Texture2dRef cinder::gl::Fbo::getColorTexture ( )

Returns a reference to the color Texture2d of the FBO (at GL_COLOR_ATTACHMENT0). Resolves multisampling and renders mipmaps if necessary. Returns an empty Ref if there is no Texture2d attached at GL_COLOR_ATTACHMENT0.

Texture2dRef cinder::gl::Fbo::getDepthTexture ( )

Returns a reference to the depth Texture2d of the FBO. Resolves multisampling and renders mipmaps if necessary. Returns an empty Ref if there is no Texture2d as a depth attachment.

Texture2dRef cinder::gl::Fbo::getTexture2d ( GLenum  attachment)

Returns a Texture2dRef attached at attachment (such as GL_COLOR_ATTACHMENT0). Resolves multisampling and renders mipmaps if necessary. Returns NULL if a Texture2d is not bound at attachment.

TextureBaseRef cinder::gl::Fbo::getTextureBase ( GLenum  attachment)

Returns a TextureBaseRef attached at attachment (such as GL_COLOR_ATTACHMENT0). Resolves multisampling and renders mipmaps if necessary. Returns NULL if a Texture is not bound at attachment.

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

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 ( int  textureUnit = 0,
GLenum  attachment = GL_COLOR_ATTACHMENT0 
)

Unbinds the texture associated with an Fbo attachment.

void cinder::gl::Fbo::bindFramebuffer ( GLenum  target = GL_FRAMEBUFFER)

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.

void cinder::gl::Fbo::resolveTextures ( ) const

Resolves internal Multisample FBO to attached Textures. Only necessary when not using getColorTexture() or getTexture(), which resolve automatically.

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

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

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

For antialiased FBOs this returns the ID of the mirror FBO designed for multisampled writing. Returns 0 otherwise.

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

Returns the resolve FBO, which is the same value as getId() without multisampling.

void cinder::gl::Fbo::markAsDirty ( )

Marks multisampling framebuffer and mipmaps as needing updates. Not generally necessary to call directly.

void cinder::gl::Fbo::blitTo ( const FboRef 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.

const std::string& cinder::gl::Fbo::getLabel ( ) const

Returns the debugging label associated with the Fbo.

void cinder::gl::Fbo::setLabel ( const std::string &  label)

Sets the debugging label associated with the Fbo. Calls glObjectLabel() when available.

Surface8u cinder::gl::Fbo::readPixels8u ( const Area area,
GLenum  attachment = GL_COLOR_ATTACHMENT0 
) const

Returns a copy of the pixels in attachment within area (cropped to the bounding rectangle of the attachment) as an 8-bit per channel Surface. attachment ignored on ES 2.

void cinder::gl::Fbo::init ( )
protected
void cinder::gl::Fbo::initMultisamplingSettings ( bool *  useMsaa,
bool *  useCsaa,
Format format 
)
protected
void cinder::gl::Fbo::prepareAttachments ( const Format format,
bool  multisampling 
)
protected
void cinder::gl::Fbo::attachAttachments ( )
protected
void cinder::gl::Fbo::initMultisample ( const Format format)
protected
void cinder::gl::Fbo::updateMipmaps ( GLenum  attachment) const
protected
bool cinder::gl::Fbo::checkStatus ( class FboExceptionInvalidSpecification resultExc)
protected
void cinder::gl::Fbo::setDrawBuffers ( GLuint  fbId,
const std::map< GLenum, RenderbufferRef > &  attachmentsBuffer,
const std::map< GLenum, TextureBaseRef > &  attachmentsTexture 
)
protected

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const Fbo rhs 
)
friend

Member Data Documentation

int cinder::gl::Fbo::mWidth
protected
int cinder::gl::Fbo::mHeight
protected
Format cinder::gl::Fbo::mFormat
protected
GLuint cinder::gl::Fbo::mId
protected
GLuint cinder::gl::Fbo::mMultisampleFramebufferId
protected
std::map<GLenum,RenderbufferRef> cinder::gl::Fbo::mAttachmentsBuffer
protected
std::map<GLenum,RenderbufferRef> cinder::gl::Fbo::mAttachmentsMultisampleBuffer
protected
std::map<GLenum,TextureBaseRef> cinder::gl::Fbo::mAttachmentsTexture
protected
std::string cinder::gl::Fbo::mLabel
protected
bool cinder::gl::Fbo::mNeedsResolve
mutableprotected
bool cinder::gl::Fbo::mNeedsMipmapUpdate
mutableprotected
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: