Ion
|
A FramebufferObject describes an off-screen framebuffer that can be drawn to and read from like a regular framebuffer. More...
#include "framebufferobject.h"
Classes | |
class | Attachment |
An attachment represents a data store attached to one of the framebuffer's targets. More... | |
Public Types | |
enum | Changes { kColorAttachmentChanged = kNumBaseChanges, kDepthAttachmentChanged, kDimensionsChanged, kStencilAttachmentChanged, kNumChanges } |
Changes that affect the resource. More... | |
enum | AttachmentBinding { kCubeMapTexture, kRenderbuffer, kTexture, kUnbound } |
The type of binding for an Attachment. More... | |
enum | BaseChanges { kLabelChanged, kResourceChanged, kNumBaseChanges } |
All ResourceHolders derived from this should start their own change enums from kNumBaseChanges. More... | |
Public Member Functions | |
FramebufferObject (uint32 width, uint32 height) | |
Creates a FramebufferObject with the passed dimensions and unbound attachments. More... | |
void | Resize (uint32 width, uint32 height) |
Resizes the FramebufferObject to the passed dimensions. More... | |
uint32 | GetWidth () const |
Gets the width of the FramebufferObject and its attachments. More... | |
uint32 | GetHeight () const |
Gets the height of the FramebufferObject and its attachments. More... | |
const Attachment & | GetColorAttachment (size_t i) const |
Gets and sets the i-th color Attachment. More... | |
void | SetColorAttachment (size_t i, const Attachment &attachment) |
const Attachment & | GetDepthAttachment () const |
Gets and sets the depth Attachment. More... | |
void | SetDepthAttachment (const Attachment &attachment) |
const Attachment & | GetStencilAttachment () const |
Gets and sets the stencil Attachment. More... | |
void | SetStencilAttachment (const Attachment &attachment) |
void | SetResource (size_t index, ResourceKey key, ResourceBase *resource) const |
Sets the resource at the passed index and key. More... | |
ResourceBase * | GetResource (size_t index, ResourceKey key) const |
Returns the Resource at the given index and key, or NULL if no resource was previously set at that location. More... | |
int | GetResourceCount () const |
Returns the number of resources that this holder holds. More... | |
size_t | GetGpuMemoryUsed () const |
Returns the total amount of GPU memory used by this Holder's resource. More... | |
const std::string & | GetLabel () const |
Returns/sets the label of this. More... | |
void | SetLabel (const std::string &label) |
void | AddReceiver (Notifier *receiver) |
Adds a Notifier to be notified. More... | |
void | RemoveReceiver (Notifier *receiver) |
Removes a Notifier to be notified. More... | |
size_t | GetReceiverCount () const |
Returns the number of Notifiers that will be notified. More... | |
const AllocatorPtr & | GetAllocator () const |
Returns the Allocator that was used for the instance. More... | |
const AllocatorPtr & | GetNonNullAllocator () const |
Return our allocator, or the default allocator if the instance was declared on the stack. More... | |
const AllocatorPtr & | GetAllocatorForLifetime (AllocationLifetime lifetime) const |
Convenience function that returns the Allocator to use to allocate an object with a specific lifetime. More... | |
void * | operator new (size_t size) |
The standard no-parameter new operator uses the default Allocator. More... | |
void * | operator new (size_t size, AllocationLifetime lifetime) |
This overloaded version of the new operator uses the AllocationManager's default Allocator for the specified lifetime. More... | |
void * | operator new (size_t size, const AllocatorPtr &allocator) |
This overloaded version of the new operator takes the Allocator to use directly as a parameter. More... | |
void * | operator new (size_t size, const AllocatorPtr &allocator, void *ptr) |
Special operator new for using placement new with Allocatables. More... | |
void * | operator new (size_t size, void *ptr) |
The placement new operator is defined conventionally. More... | |
void | operator delete (void *ptr) |
Define the delete operator to use specialized functions dealing with an Allocator. More... | |
void | operator delete (void *ptr, AllocationLifetime lifetime) |
Windows requires these (or it issues C4291 warnings). More... | |
void | operator delete (void *ptr, const AllocatorPtr &allocator) |
void | operator delete (void *ptr, void *ptr2) |
The placement delete operator does nothing, as usual. More... | |
int | GetRefCount () const |
GetRefCount() is part of the interface necessary for SharedPtr. More... | |
Static Public Member Functions | |
static bool | IsColorRenderable (uint32 gl_format) |
Returns whether the passed GL formats are renderable. More... | |
static bool | IsDepthRenderable (uint32 gl_format) |
static bool | IsStencilRenderable (uint32 gl_format) |
Protected Types | |
typedef WeakReferentPtr< Notifier > | NotifierPtr |
typedef AllocVector< NotifierPtr > | NotifierPtrVector |
Protected Member Functions | |
~FramebufferObject () override | |
The destructor is protected because all base::Referent classes must have protected or private destructors. More... | |
void | OnChanged (int bit) const |
Forwards OnChanged to all resources. More... | |
const NotifierPtrVector & | GetReceivers () const |
Returns the set of Notifiers that will be notified. More... | |
void | Notify () const |
Notifies all contained Notifiers by calling their OnNotify(). More... | |
A FramebufferObject describes an off-screen framebuffer that can be drawn to and read from like a regular framebuffer.
While the FramebufferObject is active, nothing is drawn to the screen; all draw commands draw into its Attachments.
An Attachment can be in one of three states, unbound, bound to a renderbuffer, or bound to a texture. If an attachment is unbound any data written into it is discarded. For example, if a FramebufferObject has no depth attachment then there is effectively no depth buffer.
If an Attachment is bound to a renderbuffer, Ion will allocate an internal data store (the renderbuffer) on the graphics hardware. The only way to get the data back after a draw call is through a ReadPixels command, though rendering may (depending on the platform) be faster than with a texture binding.
If an Attachment is bound to a texture, then the passed TexturePtr is used as the target for all draw commands sent to the Attachment. The Texture must contain an Image (which may have NULL data) to specify the format of the framebuffer. The Texture can then be used, for example, as a Uniform input to a shader (a sampler). Note that not all platforms support binding textures to depth and stencil Attachments. If a particular texture format is unsupported, then the Attachment will be created as unbound.
Definition at line 54 of file framebufferobject.h.
|
protectedinherited |
Definition at line 49 of file notifier.h.
|
protectedinherited |
Definition at line 50 of file notifier.h.
The type of binding for an Attachment.
Enumerator | |
---|---|
kCubeMapTexture | |
kRenderbuffer | |
kTexture | |
kUnbound |
Definition at line 66 of file framebufferobject.h.
|
inherited |
All ResourceHolders derived from this should start their own change enums from kNumBaseChanges.
Enumerator | |
---|---|
kLabelChanged | |
kResourceChanged | |
kNumBaseChanges |
Definition at line 56 of file resourceholder.h.
Changes that affect the resource.
Enumerator | |
---|---|
kColorAttachmentChanged | |
kDepthAttachmentChanged | |
kDimensionsChanged | |
kStencilAttachmentChanged | |
kNumChanges |
Definition at line 57 of file framebufferobject.h.
ion::gfx::FramebufferObject::FramebufferObject | ( | uint32 | width, |
uint32 | height | ||
) |
Creates a FramebufferObject with the passed dimensions and unbound attachments.
Definition at line 152 of file framebufferobject.cc.
References ion::port::ERROR, and LOG.
|
overrideprotected |
The destructor is protected because all base::Referent classes must have protected or private destructors.
Definition at line 163 of file framebufferobject.cc.
|
inherited |
Adds a Notifier to be notified.
Does nothing if the receiver is NULL or is already in the receiver vector.
Definition at line 25 of file notifier.cc.
|
inlineinherited |
Returns the Allocator that was used for the instance.
This will be NULL if the instance was declared on the stack or created with normal placement new.
Definition at line 68 of file allocatable.h.
References allocator_.
Referenced by ion::base::DataContainer::CreateAndCopy(), ion::text::DynamicFontImage::FindContainingImageDataIndex(), and ion::text::DynamicFontImage::FindImageDataIndex().
|
inlineinherited |
Convenience function that returns the Allocator to use to allocate an object with a specific lifetime.
Definition at line 78 of file allocatable.h.
References ion::base::Allocator::GetAllocatorForLifetime().
Referenced by ion::text::BasicBuilder::BuildVertexData(), ion::text::OutlineBuilder::BuildVertexData(), ion::gfxutils::ShaderManager::CreateShaderProgram(), ion::text::DynamicFontImage::FindContainingImageDataIndex(), ion::text::DynamicFontImage::FindImageDataIndex(), ion::gfx::Renderer::Renderer(), and ion::gfx::UpdateStateTable().
|
inline |
Gets and sets the i-th color Attachment.
For now, only a single color attachment is supported.
Definition at line 163 of file framebufferobject.h.
References DCHECK_EQ.
|
inline |
Gets and sets the depth Attachment.
Definition at line 169 of file framebufferobject.h.
|
inlineinherited |
Returns the total amount of GPU memory used by this Holder's resource.
Definition at line 78 of file resourceholder.h.
|
inline |
Gets the height of the FramebufferObject and its attachments.
Definition at line 158 of file framebufferobject.h.
|
inlineinherited |
Returns/sets the label of this.
Definition at line 89 of file resourceholder.h.
|
inlineinherited |
Return our allocator, or the default allocator if the instance was declared on the stack.
Definition at line 72 of file allocatable.h.
References allocator_, and ion::base::AllocationManager::GetNonNullAllocator().
|
inherited |
Returns the number of Notifiers that will be notified.
Definition at line 71 of file notifier.cc.
|
protectedinherited |
Returns the set of Notifiers that will be notified.
Definition at line 77 of file notifier.cc.
|
inlineinherited |
GetRefCount() is part of the interface necessary for SharedPtr.
Definition at line 34 of file shareable.h.
Referenced by ion::base::Notifier::RemoveReceiver().
|
inherited |
Returns the Resource at the given index and key, or NULL if no resource was previously set at that location.
Definition at line 122 of file resourceholder.cc.
|
inlineinherited |
Returns the number of resources that this holder holds.
Note that this is not necessarily the number of indices that have non-NULL resources. This can be used as a fast trivial check to see if the holder has any resources.
Definition at line 73 of file resourceholder.h.
|
inline |
Gets and sets the stencil Attachment.
Definition at line 172 of file framebufferobject.h.
|
inline |
Gets the width of the FramebufferObject and its attachments.
Definition at line 156 of file framebufferobject.h.
|
static |
Returns whether the passed GL formats are renderable.
Definition at line 187 of file framebufferobject.cc.
|
static |
Definition at line 207 of file framebufferobject.cc.
|
static |
Definition at line 213 of file framebufferobject.cc.
|
protectedinherited |
Notifies all contained Notifiers by calling their OnNotify().
Any receivers that have been destroyed will be removed from the vector of receivers.
Definition at line 81 of file notifier.cc.
References ion::base::SharedPtr< T >::Get().
|
inlineprotectedinherited |
Forwards OnChanged to all resources.
Definition at line 326 of file resourceholder.h.
|
inlineinherited |
Define the delete operator to use specialized functions dealing with an Allocator.
Definition at line 109 of file allocatable.h.
|
inlineinherited |
Windows requires these (or it issues C4291 warnings).
Definition at line 112 of file allocatable.h.
|
inlineinherited |
Definition at line 113 of file allocatable.h.
|
inlineinherited |
The placement delete operator does nothing, as usual.
Definition at line 118 of file allocatable.h.
|
inlineinherited |
The standard no-parameter new operator uses the default Allocator.
Definition at line 84 of file allocatable.h.
|
inlineinherited |
This overloaded version of the new operator uses the AllocationManager's default Allocator for the specified lifetime.
Definition at line 88 of file allocatable.h.
|
inlineinherited |
This overloaded version of the new operator takes the Allocator to use directly as a parameter.
If the Allocator pointer is NULL, this uses the default Allocator.
Definition at line 95 of file allocatable.h.
|
inlineinherited |
Special operator new for using placement new with Allocatables.
Definition at line 100 of file allocatable.h.
|
inlineinherited |
The placement new operator is defined conventionally.
Definition at line 105 of file allocatable.h.
|
inherited |
Removes a Notifier to be notified.
Does nothing if the receiver is NULL or not in the set of receivers.
Definition at line 38 of file notifier.cc.
References ion::base::Shareable::GetRefCount().
Referenced by ion::gfx::AttributeArray::~AttributeArray().
void ion::gfx::FramebufferObject::Resize | ( | uint32 | width, |
uint32 | height | ||
) |
Resizes the FramebufferObject to the passed dimensions.
Definition at line 169 of file framebufferobject.cc.
void ion::gfx::FramebufferObject::SetColorAttachment | ( | size_t | i, |
const Attachment & | attachment | ||
) |
Definition at line 174 of file framebufferobject.cc.
References DCHECK_EQ.
void ion::gfx::FramebufferObject::SetDepthAttachment | ( | const Attachment & | attachment | ) |
Definition at line 179 of file framebufferobject.cc.
|
inlineinherited |
Definition at line 90 of file resourceholder.h.
|
inherited |
Sets the resource at the passed index and key.
The size of the internal vector is automatically managed so that it has the smallest possible size.
Definition at line 51 of file resourceholder.cc.
References DCHECK, DCHECK_EQ, ion::gfx::ResourceBase::GetKey(), and ion::gfx::ResourceBase::OnChanged().
void ion::gfx::FramebufferObject::SetStencilAttachment | ( | const Attachment & | attachment | ) |
Definition at line 183 of file framebufferobject.cc.