24 #ifndef PXR_IMAGING_GLF_DRAW_TARGET_H 25 #define PXR_IMAGING_GLF_DRAW_TARGET_H 30 #include "pxr/imaging/glf/api.h" 32 #include "pxr/imaging/garch/glApi.h" 46 PXR_NAMESPACE_OPEN_SCOPE
50 typedef std::shared_ptr<class GlfGLContext> GlfGLContextSharedPtr;
75 static GlfDrawTargetRefPtr
New(
GfVec2i const & size,
76 bool requestMSAA =
false );
87 static GlfDrawTargetRefPtr
New( GlfDrawTargetPtr
const & drawtarget );
95 GLenum internalFormat,
GfVec2i size,
96 unsigned int numSamples);
99 ~Attachment()
override;
102 GLuint GetGlTextureName()
override;
105 GLuint GetGlTextureMSName()
const {
return _textureNameMS; }
108 GLenum GetFormat()
const {
return _format; }
111 GLenum GetType()
const {
return _type; }
114 GLenum GetInternalFormat()
const {
return _internalFormat; }
117 int GetAttach()
const {
return _glIndex; }
121 void ResizeTexture(
const GfVec2i &size);
125 BindingVector GetBindings(
TfToken const & identifier,
126 GLuint samplerName)
override;
137 Attachment(
int glIndex, GLenum format, GLenum type,
138 GLenum internalFormat,
GfVec2i size,
139 unsigned int numSamples);
142 void _DeleteTexture();
145 GLuint _textureNameMS;
155 unsigned int _numSamples;
160 typedef std::map<std::string, AttachmentRefPtr> AttachmentsMap;
165 GLenum format, GLenum type, GLenum internalFormat );
190 std::string
const & filename,
202 bool HasMSAA()
const {
return (_numSamples > 1); }
232 static void Resolve(
const std::vector<GlfDrawTarget*>& drawTargets);
244 bool IsValid(std::string * reason = NULL);
253 AttachmentsMap attachments;
266 void _GenFrameBuffer();
270 GLuint _AllocAttachment( GLenum format, GLenum type );
272 AttachmentsMap & _GetAttachments()
const;
274 void _DeleteAttachments( );
278 bool _Validate(std::string * reason = NULL);
280 void _SaveBindingState();
282 void _RestoreBindingState();
287 GLuint _framebufferMS;
289 GLuint _unbindRestoreReadFB,
290 _unbindRestoreDrawFB;
296 unsigned int _numSamples;
299 GlfGLContextSharedPtr _owningContext;
303 PXR_NAMESPACE_CLOSE_SCOPE
305 #endif // GLF_DRAW_TARGET_H GLF_API void SetSize(GfVec2i)
Resize the DrawTarget.
GLF_API void Unbind()
Unbinds the framebuffer.
GLF_API bool IsValid(std::string *reason=NULL)
Returns whether the enclosed framebuffer object is complete.
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 DeleteAttachment(std::string const &name)
Removes the named attachment from the DrawTarget.
Basic type for a vector of 2 int components.
Standard pointer typedefs.
GLF_API void Resolve()
Resolve the MSAA framebuffer to a regular framebuffer.
static GLF_API GlfDrawTargetRefPtr New(GfVec2i const &size, bool requestMSAA=false)
Returns a new instance.
GLF_API void AddAttachment(std::string const &name, GLenum format, GLenum type, GLenum internalFormat)
Add an attachment to the DrawTarget.
A map with string keys and VtValue values.
#define TF_DECLARE_WEAK_AND_REF_PTRS(type)
Define standard weak, ref, and vector pointer types.
A class representing a GL render target with mutliple image attachments.
GLF_API void CloneAttachments(GlfDrawTargetPtr const &drawtarget)
Copies the list of attachments from DrawTarget.
Enable a concrete base class for use with TfRefPtr.
Token for efficient comparison, assignment, and hashing of known strings.
Stores a 4x4 matrix of double elements.
GLF_API GLuint GetFramebufferId() const
Returns the framebuffer object Id.
bool HasMSAA() const
Returns if the draw target uses msaa.
GLF_API void TouchContents()
Updates the contents signature for attached textures to allow downstream consumers to know that the t...
Weak/Ref-based container for the the map of texture attachments.
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 AttachmentsMap const & GetAttachments() const
Returns the list of Attachments for this DrawTarget.
GLF_API bool IsBound() const
Returns whether the framebuffer is currently bound.
Represents a texture object in Glf.
Reference-counted smart pointer utility class.
GLF_API void ClearAttachments()
Clears all the attachments for this DrawTarget.
GfVec2i const & GetSize() const
Returns the size of the DrawTarget.
Enable a concrete base class for use with TfWeakPtr.
GLF_API AttachmentRefPtr GetAttachment(std::string const &name)
Returns the attachment with a given name or TfNullPtr;.