All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GlfDrawTarget Class Reference

A class representing a GL render target with mutliple image attachments. More...

+ Inheritance diagram for GlfDrawTarget:

Classes

class  AttachmentsContainer
 Weak/Ref-based container for the the map of texture attachments. More...
 

Public Types

typedef GlfDrawTarget This
 
typedef TfDeclarePtrs< class
Attachment >::RefPtr 
AttachmentRefPtr
 
typedef std::map< std::string,
AttachmentRefPtr
AttachmentsMap
 
- Public Types inherited from TfRefBase
typedef void(* UniqueChangedFuncPtr )(TfRefBase const *, bool)
 

Public Member Functions

GLF_API void AddAttachment (std::string const &name, GLenum format, GLenum type, GLenum internalFormat)
 Add an attachment to the DrawTarget. More...
 
GLF_API void DeleteAttachment (std::string const &name)
 Removes the named attachment from the DrawTarget. More...
 
GLF_API void ClearAttachments ()
 Clears all the attachments for this DrawTarget. More...
 
GLF_API void CloneAttachments (GlfDrawTargetPtr const &drawtarget)
 Copies the list of attachments from DrawTarget. More...
 
GLF_API AttachmentsMap const & GetAttachments () const
 Returns the list of Attachments for this DrawTarget. More...
 
GLF_API AttachmentRefPtr GetAttachment (std::string const &name)
 Returns the attachment with a given name or TfNullPtr;. More...
 
GLF_API bool WriteToFile (std::string const &name, std::string const &filename, GfMatrix4d const &viewMatrix=GfMatrix4d(1), GfMatrix4d const &projectionMatrix=GfMatrix4d(1))
 Write the Attachment buffer to an image file (debugging). More...
 
GLF_API void SetSize (GfVec2i)
 Resize the DrawTarget. More...
 
GfVec2i const & GetSize () const
 Returns the size of the DrawTarget. More...
 
bool HasMSAA () const
 Returns if the draw target uses msaa. More...
 
GLF_API GLuint GetFramebufferId () const
 Returns the framebuffer object Id. More...
 
GLF_API GLuint GetFramebufferMSId () const
 Returns the id of the framebuffer object with MSAA buffers. More...
 
GLF_API void Bind ()
 Binds the framebuffer. More...
 
GLF_API void Unbind ()
 Unbinds the framebuffer. More...
 
GLF_API bool IsBound () const
 Returns whether the framebuffer is currently bound. More...
 
GLF_API void Resolve ()
 Resolve the MSAA framebuffer to a regular framebuffer. More...
 
GLF_API void TouchContents ()
 Updates the contents signature for attached textures to allow downstream consumers to know that the texture image data may have changed. More...
 
GLF_API bool IsValid (std::string *reason=NULL)
 Returns whether the enclosed framebuffer object is complete. More...
 
- Public Member Functions inherited from TfRefBase
size_t GetCurrentCount () const
 Return the current reference count of this object. More...
 
bool IsUnique () const
 Return true if only one TfRefPtr points to this object. More...
 
const TfRefCountGetRefCount () const
 
void SetShouldInvokeUniqueChangedListener (bool shouldCall)
 
- Public Member Functions inherited from TfWeakBase
 TfWeakBase (const TfWeakBase &)
 
const TfWeakBase__GetTfWeakBase__ () const
 
const TfWeakBaseoperator= (const TfWeakBase &)
 
void EnableNotification2 () const
 
TF_API void const * GetUniqueIdentifier () const
 

Static Public Member Functions

static GLF_API GlfDrawTargetRefPtr New (GfVec2i const &size, bool requestMSAA=false)
 Returns a new instance. More...
 
static GLF_API GlfDrawTargetRefPtr New (GlfDrawTargetPtr const &drawtarget)
 Returns a new instance. More...
 
static GLF_API void Resolve (const std::vector< GlfDrawTarget * > &drawTargets)
 Resolve several MSAA framebuffers at once. More...
 
- Static Public Member Functions inherited from TfRefBase
static TF_API void SetUniqueChangedListener (UniqueChangedListener listener)
 

Protected Member Functions

GLF_API GlfDrawTarget (GfVec2i const &size, bool requestMSAA)
 
GLF_API GlfDrawTarget (GlfDrawTargetPtr const &drawtarget)
 
- Protected Member Functions inherited from TfWeakBase
TfRefPtr< Tf_Remnant > _Register () const
 
template<class T >
TfRefPtr< Tf_Remnant > _Register (T *tempRmnt) const
 
bool _HasRemnant () const
 

Detailed Description

A class representing a GL render target with mutliple image attachments.

A DrawTarget is essentially a custom render pass into which several arbitrary variables can be output into. These can later be used as texture samplers by GLSL shaders.

The DrawTarget maintains a map of named attachments that correspond to GL_TEXTURE_2D mages. By default, DrawTargets also create a depth component that is used both as a depth buffer during the draw pass, and can later be accessed as a regular GL_TEXTURE_2D data. Stencils are also available (by setting the format to GL_DEPTH_STENCIL and the internalFormat to GL_DEPTH24_STENCIL8)

Definition at line 67 of file drawTarget.h.

Member Function Documentation

GLF_API void AddAttachment ( std::string const &  name,
GLenum  format,
GLenum  type,
GLenum  internalFormat 
)

Add an attachment to the DrawTarget.

GLF_API void Bind ( )

Binds the framebuffer.

GLF_API void ClearAttachments ( )

Clears all the attachments for this DrawTarget.

GLF_API void CloneAttachments ( GlfDrawTargetPtr const &  drawtarget)

Copies the list of attachments from DrawTarget.

GLF_API void DeleteAttachment ( std::string const &  name)

Removes the named attachment from the DrawTarget.

GLF_API AttachmentRefPtr GetAttachment ( std::string const &  name)

Returns the attachment with a given name or TfNullPtr;.

GLF_API AttachmentsMap const& GetAttachments ( ) const

Returns the list of Attachments for this DrawTarget.

GLF_API GLuint GetFramebufferId ( ) const

Returns the framebuffer object Id.

GLF_API GLuint GetFramebufferMSId ( ) const

Returns the id of the framebuffer object with MSAA buffers.

GfVec2i const& GetSize ( ) const
inline

Returns the size of the DrawTarget.

Definition at line 199 of file drawTarget.h.

bool HasMSAA ( ) const
inline

Returns if the draw target uses msaa.

Definition at line 202 of file drawTarget.h.

GLF_API bool IsBound ( ) const

Returns whether the framebuffer is currently bound.

GLF_API bool IsValid ( std::string *  reason = NULL)

Returns whether the enclosed framebuffer object is complete.

If reason is non-NULL, and this framebuffer is not valid, sets reason to the reason why not.

static GLF_API GlfDrawTargetRefPtr New ( GfVec2i const &  size,
bool  requestMSAA = false 
)
static

Returns a new instance.

static GLF_API GlfDrawTargetRefPtr New ( GlfDrawTargetPtr const &  drawtarget)
static

Returns a new instance.

GL framebuffers cannot be shared across contexts, but texture attachments can. In order to reflect this, GlfDrawTargets hold onto their maps of attachments through a RefPtr that can be shared by multiple GlfDrawTargets, one for each of the active GL contexts (ex. one for each active QT viewer). This constructor creates a new framebuffer, but populates its map of attachments by sharing the RefPtr of the source GlfDrawTarget.

GLF_API void Resolve ( )

Resolve the MSAA framebuffer to a regular framebuffer.

If there is no MSAA enabled, this function does nothing.

static GLF_API void Resolve ( const std::vector< GlfDrawTarget * > &  drawTargets)
static

Resolve several MSAA framebuffers at once.

If any framebuffers don't have MSAA enabled, nothing happens to them.

GLF_API void SetSize ( GfVec2i  )

Resize the DrawTarget.

GLF_API void TouchContents ( )

Updates the contents signature for attached textures to allow downstream consumers to know that the texture image data may have changed.

GLF_API void Unbind ( )

Unbinds the framebuffer.

GLF_API bool WriteToFile ( std::string const &  name,
std::string const &  filename,
GfMatrix4d const &  viewMatrix = GfMatrix4d(1),
GfMatrix4d const &  projectionMatrix = GfMatrix4d(1) 
)

Write the Attachment buffer to an image file (debugging).


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