Loading...
Searching...
No Matches
GlfDrawTarget Class Reference

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

#include <drawTarget.h>

+ 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< classAttachment >::RefPtr AttachmentRefPtr
 
typedef std::map< std::string, AttachmentRefPtrAttachmentsMap
 
- 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.
 
GLF_API void DeleteAttachment (std::string const &name)
 Removes the named attachment from the DrawTarget.
 
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 AttachmentsMap const & GetAttachments () const
 Returns the list of Attachments for this DrawTarget.
 
GLF_API AttachmentRefPtr GetAttachment (std::string const &name)
 Returns the attachment with a given name or TfNullPtr;.
 
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).
 
GLF_API void SetSize (GfVec2i)
 Resize the DrawTarget.
 
GfVec2i const & GetSize () const
 Returns the size of the DrawTarget.
 
bool HasMSAA () const
 Returns if the draw target uses msaa.
 
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.
 
GLF_API void Bind ()
 Binds the framebuffer.
 
GLF_API void Unbind ()
 Unbinds the framebuffer.
 
GLF_API bool IsBound () const
 Returns whether the framebuffer is currently bound.
 
GLF_API void Resolve ()
 Resolve the MSAA framebuffer to a regular framebuffer.
 
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 bool IsValid (std::string *reason=NULL)
 Returns whether the enclosed framebuffer object is complete.
 
- Public Member Functions inherited from TfRefBase
 TfRefBase (TfRefBase const &)
 
TfRefBaseoperator= (TfRefBase const &)
 
size_t GetCurrentCount () const
 Return the current reference count of this object.
 
bool IsUnique () const
 Return true if only one TfRefPtr points to this object.
 
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.
 
static GLF_API GlfDrawTargetRefPtr New (GlfDrawTargetPtr const &drawtarget)
 Returns a new instance.
 
static GLF_API void Resolve (const std::vector< GlfDrawTarget * > &drawTargets)
 Resolve several MSAA framebuffers at once.
 
- 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 Typedef Documentation

◆ AttachmentRefPtr

typedef TfDeclarePtrs<classAttachment>::RefPtr AttachmentRefPtr

Definition at line 158 of file drawTarget.h.

◆ AttachmentsMap

typedef std::map<std::string, AttachmentRefPtr> AttachmentsMap

Definition at line 160 of file drawTarget.h.

◆ This

Definition at line 69 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: