#include <FrameBuffer.h>
Public Member Functions | |
const char * | getId () const |
unsigned int | getWidth () const |
unsigned int | getHeight () const |
void | setRenderTarget (RenderTarget *target, unsigned int index=0) |
void | setRenderTarget (RenderTarget *target, Texture::CubeFace face, unsigned int index=0) |
RenderTarget * | getRenderTarget (unsigned int index=0) const |
unsigned int | getRenderTargetCount () const |
void | setDepthStencilTarget (DepthStencilTarget *target) |
DepthStencilTarget * | getDepthStencilTarget () const |
bool | isDefault () const |
FrameBuffer * | bind () |
Static Public Member Functions | |
static FrameBuffer * | create (const char *id) |
static FrameBuffer * | create (const char *id, unsigned int width, unsigned int height) |
static FrameBuffer * | getFrameBuffer (const char *id) |
static unsigned int | getMaxRenderTargets () |
static Image * | createScreenshot (Image::Format format=Image::RGBA) |
static void | getScreenshot (Image *image) |
static FrameBuffer * | bindDefault () |
static FrameBuffer * | getCurrent () |
Defines a frame buffer object that may contain one or more render targets and optionally a depth-stencil target.
Frame buffers can be created and used for off-screen rendering, which is useful for techniques such as shadow mapping and post-processing. Render targets within a frame buffer can be both written to and read (by calling RenderTarget::getTexture).
When binding a custom frame buffer, you should always store the return value of FrameBuffer::bind and restore it when you are finished drawing to your frame buffer.
To bind the default frame buffer, call FrameBuffer::bindDefault.
Binds this FrameBuffer for off-screen rendering and return you the currently bound one.
You should keep the return FrameBuffer and store it and call bind() when you rendering is complete.
@ return The currently bound framebuffer.
static FrameBuffer* gameplay::FrameBuffer::bindDefault | ( | ) | [static] |
Binds the default FrameBuffer for rendering to the display.
@ return The default framebuffer.
static FrameBuffer* gameplay::FrameBuffer::create | ( | const char * | id | ) | [static] |
Creates a new, empty FrameBuffer object.
The new FrameBuffer does not have any render targets or a depth/stencil target and these must be added before it can be used. The FrameBuffer is added to the list of available FrameBuffers.
id | The ID of the new FrameBuffer. Uniqueness is recommended but not enforced. |
static FrameBuffer* gameplay::FrameBuffer::create | ( | const char * | id, |
unsigned int | width, | ||
unsigned int | height | ||
) | [static] |
Creates a new FrameBuffer with a single RenderTarget of the specified width and height, and adds the FrameBuffer to the list of available FrameBuffers.
If width and height are non-zero a default RenderTarget of type RGBA will be created and added to the FrameBuffer, with the same ID. The ID of the render target can be changed later via RenderTarget::setId(const char*).
You can additionally add a DepthStencilTarget using FrameBuffer::setDepthStencilTarget.
id | The ID of the new FrameBuffer. Uniqueness is recommended but not enforced. |
width | The width of the RenderTarget to be created and attached. |
height | The height of the RenderTarget to be created and attached. |
static Image* gameplay::FrameBuffer::createScreenshot | ( | Image::Format | format = Image::RGBA | ) | [static] |
Records a screenshot of what is stored on the current FrameBuffer.
format | The format the Image should be in. |
static FrameBuffer* gameplay::FrameBuffer::getCurrent | ( | ) | [static] |
Gets the currently bound FrameBuffer.
Get this FrameBuffer's DepthStencilTarget.
static FrameBuffer* gameplay::FrameBuffer::getFrameBuffer | ( | const char * | id | ) | [static] |
Get a named FrameBuffer from its ID.
id | The ID of the FrameBuffer to search for. |
unsigned int gameplay::FrameBuffer::getHeight | ( | ) | const |
Gets the height of the frame buffer.
const char* gameplay::FrameBuffer::getId | ( | ) | const |
Get the ID of this FrameBuffer.
static unsigned int gameplay::FrameBuffer::getMaxRenderTargets | ( | ) | [static] |
Get the number of color attachments available on the current hardware.
RenderTarget* gameplay::FrameBuffer::getRenderTarget | ( | unsigned int | index = 0 | ) | const |
Get the RenderTarget attached to the FrameBuffer's color attachment at the specified index.
index | The index of the color attachment to retrieve a RenderTarget from. |
unsigned int gameplay::FrameBuffer::getRenderTargetCount | ( | ) | const |
Returns the current number of render targets attached to this frame buffer.
static void gameplay::FrameBuffer::getScreenshot | ( | Image * | image | ) | [static] |
Records a screenshot of what is stored on the current FrameBuffer to an Image.
The Image must be the same size as the FrameBuffer, otherwise the operation will fail.
image | The Image to write the current framebuffer's content to. |
unsigned int gameplay::FrameBuffer::getWidth | ( | ) | const |
Gets the width of the frame buffer.
bool gameplay::FrameBuffer::isDefault | ( | ) | const |
Determines whether this is the default frame buffer.
void gameplay::FrameBuffer::setDepthStencilTarget | ( | DepthStencilTarget * | target | ) |
Set this FrameBuffer's DepthStencilTarget.
target | The DepthStencilTarget to set on this FrameBuffer. |
void gameplay::FrameBuffer::setRenderTarget | ( | RenderTarget * | target, |
unsigned int | index = 0 |
||
) |
Set a RenderTarget on this FrameBuffer's color attachment at the specified index.
target | The 2D RenderTarget to set. |
index | The index of the color attachment to set. |
void gameplay::FrameBuffer::setRenderTarget | ( | RenderTarget * | target, |
Texture::CubeFace | face, | ||
unsigned int | index = 0 |
||
) |
Set a RenderTarget on this FrameBuffer's color attachment at the specified index.
target | The Cubemap RenderTarget to set. |
face | The face of the cubemap to target. |
index | The index of the color attachment to set. |