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 TfRefCount & GetRefCount () const
 
void SetShouldInvokeUniqueChangedListener (bool shouldCall)
 
- Public Member Functions inherited from TfWeakBase
 TfWeakBase (const TfWeakBase &)
 
const TfWeakBase & __GetTfWeakBase__ () const
 
const TfWeakBase & operator= (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

◆ AddAttachment()

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

Add an attachment to the DrawTarget.

◆ Bind()

GLF_API void Bind ( )

Binds the framebuffer.

◆ ClearAttachments()

GLF_API void ClearAttachments ( )

Clears all the attachments for this DrawTarget.

◆ CloneAttachments()

GLF_API void CloneAttachments ( GlfDrawTargetPtr const &  drawtarget)

Copies the list of attachments from DrawTarget.

◆ DeleteAttachment()

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

Removes the named attachment from the DrawTarget.

◆ GetAttachment()

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

Returns the attachment with a given name or TfNullPtr;.

◆ GetAttachments()

GLF_API AttachmentsMap const& GetAttachments ( ) const

Returns the list of Attachments for this DrawTarget.

◆ GetFramebufferId()

GLF_API GLuint GetFramebufferId ( ) const

Returns the framebuffer object Id.

◆ GetFramebufferMSId()

GLF_API GLuint GetFramebufferMSId ( ) const

Returns the id of the framebuffer object with MSAA buffers.

◆ GetSize()

GfVec2i const& GetSize ( ) const
inline

Returns the size of the DrawTarget.

Definition at line 199 of file drawTarget.h.

◆ HasMSAA()

bool HasMSAA ( ) const
inline

Returns if the draw target uses msaa.

Definition at line 202 of file drawTarget.h.

◆ IsBound()

GLF_API bool IsBound ( ) const

Returns whether the framebuffer is currently bound.

◆ IsValid()

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.

◆ New() [1/2]

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

Returns a new instance.

◆ New() [2/2]

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.

◆ Resolve() [1/2]

GLF_API void Resolve ( )

Resolve the MSAA framebuffer to a regular framebuffer.

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

◆ Resolve() [2/2]

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.

◆ SetSize()

GLF_API void SetSize ( GfVec2i  )

Resize the DrawTarget.

◆ TouchContents()

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.

◆ Unbind()

GLF_API void Unbind ( )

Unbinds the framebuffer.

◆ WriteToFile()

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: