LiteFX::Rendering::IFrameBuffer
The interface for a frame buffer.
Synopsis
Declared in <litefx/rendering_api.hpp>
class [[dllimport, dllexport]] IFrameBuffer
: public virtual IStateResource
, public SharedObject
Description
A frame buffer is a set of images of equal size, that are used by render targets and/or input attachments in a IRenderPass. When creating a new frame buffer, it is empty by default and needs images to be added into it. When beginning a render pass during rendering, a frame buffer instance needs to be passed to it. The render pass then tries to obtain an image for each render target from the frame buffer. It does this by resolving it's render targets (IRenderPass::renderTargets). A render target stores a unique identifier (IRenderTarget::identifier), that is used to obtain the image. Before this resolution process can be successful, the render targets must first be mapped to the images in the frame buffer by calling IFrameBuffer::mapRenderTarget. Calling this method multiple times will overwrite the mapping. It is also possible to remove a render target mapping by calling IFrameBuffer::unmapRenderTarget. This will result in future attempts to resolve this render target using the frame buffer instance to fail.
The images in the frame buffer can be resized by calling IFrameBuffer::resize. As this involves re-creating the images, it is important to properly synchronize resizing with rendering, i.e., resizing while a frame is still being rendered is not allowed. Calling IFrameBuffer::resize invokes two events, IFrameBuffer::resizing before the actual resize occurs and IFrameBuffer::resized afterwards.
The main purpose of those events is to provide convenient points for manually controlling image allocation for the frame buffer. Whenever the frame buffer needs to create a new image instance, it checks, if a IFrameBuffer::allocation_callback_type has been provided during initialization. If provided, this callback is invoked instead of directly creating the image. Only if the callback returns nullptr, the frame buffer will proceed with the default behavior of allocating the image itself. This way, it is possible to selectively deviate from the default image allocation behavior, for example to allocate a fixed-size image or to provide pre-allocated images, which can be helpful if render targets should be aliased.
Base Classes
Types
| Name | Description |
ReleasedEventArgs | Event arguments that are published to subscribers when a frame buffer gets released. |
ResizeEventArgs | Event arguments that are published to subscribers when a frame buffer gets resized. |
Type Aliases
Member Functions
| Name | Description |
~IFrameBuffer [destructor] [virtual] | Releases the frame buffer. |
addImage | addImage overloads |
addImages | Adds multiple images for a set of render targets to the frame buffer. |
getHeight [virtual] | Returns the current height of the frame buffer. |
getWidth [virtual] | Returns the current width of the frame buffer. |
image | image overloads |
images | Returns all images contained by the frame buffer. |
mapRenderTarget | mapRenderTarget overloads |
mapRenderTargets | Maps a set of render targets to the frame buffer images, using the names of the render targets to look up the images. |
name [virtual] | Returns the name of the resource. |
operator[] | Subscript operators |
resize [virtual] | Causes the frame buffer to be invalidated and recreated with a new size. |
resolveImage [virtual] | Resolves a render target name hash and returns the image mapped to it. |
shared_from_this | Returns a shared pointer to the current object instance. |
size [virtual] | Returns the current size of the frame buffer. |
unmapRenderTarget [virtual] | Removes a mapping between a render target and an image in the frame buffer. |
weak_from_this | Returns a weak pointer to the current object instance. |
Data Members
| Name | Description |
released | Invoked when the frame buffer gets released. |
resized | Invoked after the frame buffer has been resized. |
resizing | Invoked if the frame buffer gets resized. |
Protected Types
| Name | Description |
Allocator | An allocator used to allocate the shared object. |
Protected Member Functions
Protected Static Member Functions
| Name | Description |
create | Generic factory method used to create instances of the shared object. |
Derived Classes
| Name | Description |
FrameBuffer | Stores the images used by a RenderPass to either read from using input attachments or write to using render targets. |
FrameBuffer | Stores the images used by a RenderPass to either read from using input attachments or write to using render targets. |