7#ifndef PXR_IMAGING_GLF_DRAW_TARGET_H
8#define PXR_IMAGING_GLF_DRAW_TARGET_H
13#include "pxr/imaging/glf/api.h"
15#include "pxr/imaging/garch/glApi.h"
29PXR_NAMESPACE_OPEN_SCOPE
33typedef std::shared_ptr<class GlfGLContext> GlfGLContextSharedPtr;
59 bool requestMSAA =
false );
70 static GlfDrawTargetRefPtr
New( GlfDrawTargetPtr
const & drawtarget );
78 GLenum internalFormat,
GfVec2i size,
79 unsigned int numSamples);
82 ~Attachment()
override;
85 GLuint GetGlTextureName()
override;
88 GLuint GetGlTextureMSName()
const {
return _textureNameMS; }
91 GLenum GetFormat()
const {
return _format; }
94 GLenum GetType()
const {
return _type; }
97 GLenum GetInternalFormat()
const {
return _internalFormat; }
100 int GetAttach()
const {
return _glIndex; }
104 void ResizeTexture(
const GfVec2i &size);
108 BindingVector GetBindings(
TfToken const & identifier,
109 GLuint samplerName)
override;
117 void TouchContents();
120 Attachment(
int glIndex, GLenum format, GLenum type,
121 GLenum internalFormat,
GfVec2i size,
122 unsigned int numSamples);
125 void _DeleteTexture();
128 GLuint _textureNameMS;
138 unsigned int _numSamples;
143 typedef std::map<std::string, AttachmentRefPtr> AttachmentsMap;
148 GLenum format, GLenum type, GLenum internalFormat );
173 std::string
const & filename,
185 bool HasMSAA()
const {
return (_numSamples > 1); }
215 static void Resolve(
const std::vector<GlfDrawTarget*>& drawTargets);
236 AttachmentsMap attachments;
249 void _GenFrameBuffer();
253 GLuint _AllocAttachment( GLenum format, GLenum type );
255 AttachmentsMap & _GetAttachments()
const;
257 void _DeleteAttachments( );
261 bool _Validate(std::string * reason = NULL);
263 void _SaveBindingState();
265 void _RestoreBindingState();
270 GLuint _framebufferMS;
272 GLuint _unbindRestoreReadFB,
273 _unbindRestoreDrawFB;
279 unsigned int _numSamples;
282 GlfGLContextSharedPtr _owningContext;
286PXR_NAMESPACE_CLOSE_SCOPE
Stores a 4x4 matrix of double elements.
Basic type for a vector of 2 int components.
Weak/Ref-based container for the the map of texture attachments.
A class representing a GL render target with mutliple image attachments.
GLF_API AttachmentsMap const & GetAttachments() const
Returns the list of Attachments for this DrawTarget.
GLF_API void AddAttachment(std::string const &name, GLenum format, GLenum type, GLenum internalFormat)
Add an attachment to the DrawTarget.
GLF_API bool IsBound() const
Returns whether the framebuffer is currently bound.
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.
GLF_API AttachmentRefPtr GetAttachment(std::string const &name)
Returns the attachment with a given name or TfNullPtr;.
GLF_API void ClearAttachments()
Clears all the attachments for this DrawTarget.
GLF_API bool IsValid(std::string *reason=NULL)
Returns whether the enclosed framebuffer object is complete.
GLF_API GLuint GetFramebufferId() const
Returns the framebuffer object Id.
GLF_API void DeleteAttachment(std::string const &name)
Removes the named attachment from the DrawTarget.
GLF_API void CloneAttachments(GlfDrawTargetPtr const &drawtarget)
Copies the list of attachments from DrawTarget.
GLF_API GLuint GetFramebufferMSId() const
Returns the id of the framebuffer object with MSAA buffers.
GLF_API void TouchContents()
Updates the contents signature for attached textures to allow downstream consumers to know that the t...
GfVec2i const & GetSize() const
Returns the size of the DrawTarget.
GLF_API void Bind()
Binds the framebuffer.
GLF_API void SetSize(GfVec2i)
Resize the DrawTarget.
static GLF_API GlfDrawTargetRefPtr New(GfVec2i const &size, bool requestMSAA=false)
Returns a new instance.
bool HasMSAA() const
Returns if the draw target uses msaa.
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).
GLF_API void Resolve()
Resolve the MSAA framebuffer to a regular framebuffer.
Represents a texture object in Glf.
Enable a concrete base class for use with TfRefPtr.
Reference-counted smart pointer utility class.
Token for efficient comparison, assignment, and hashing of known strings.
Enable a concrete base class for use with TfWeakPtr.
A map with string keys and VtValue values.
Standard pointer typedefs.
#define TF_DECLARE_WEAK_AND_REF_PTRS(type)
Define standard weak, ref, and vector pointer types.