|  | overview |  | wiki |  | api reference |  | download

- Main Page
- Classes

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Functions Variables Typedefs Enumerations Enumerator
Public Member Functions | Static Public Member Functions
gameplay::FrameBuffer Class Reference

`#include <FrameBuffer.h>`

Inheritance diagram for gameplay::FrameBuffer:

List of all members.

## 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 ()

## Detailed Description

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.

## Member Function Documentation

FrameBuffer* gameplay::FrameBuffer::bind | ( |  | ) |

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.

Parameters:

  id | The ID of the new FrameBuffer. Uniqueness is recommended but not enforced.

Returns:
  A newly created FrameBuffer.

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.

Parameters:

  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.

Returns:
  A newly created FrameBuffer.

static Image* gameplay::FrameBuffer::createScreenshot | ( | Image::Format | format = `Image::RGBA` | ) | `[static]`

Records a screenshot of what is stored on the current FrameBuffer.

Parameters:

  format | The format the Image should be in.

Returns:
  A screenshot of the current framebuffer's content.

static FrameBuffer* gameplay::FrameBuffer::getCurrent | ( |  | ) | `[static]`

Gets the currently bound FrameBuffer.

Returns:
  The currently bound FrameBuffer.

DepthStencilTarget* gameplay::FrameBuffer::getDepthStencilTarget | ( |  | ) | const

Get this FrameBuffer's DepthStencilTarget.

Returns:
  This FrameBuffer's DepthStencilTarget.

static FrameBuffer* gameplay::FrameBuffer::getFrameBuffer | ( | const char * | id | ) | `[static]`

Get a named FrameBuffer from its ID.

Parameters:

  id | The ID of the FrameBuffer to search for.

Returns:
  The FrameBuffer with the specified ID, or NULL if one was not found.

unsigned int gameplay::FrameBuffer::getHeight | ( |  | ) | const

Gets the height of the frame buffer.

Returns:
  The height of the frame buffer.

const char* gameplay::FrameBuffer::getId | ( |  | ) | const

Get the ID of this FrameBuffer.

Returns:
  The ID of this FrameBuffer.

static unsigned int gameplay::FrameBuffer::getMaxRenderTargets | ( |  | ) | `[static]`

Get the number of color attachments available on the current hardware.

Returns:
  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.

Parameters:

  index | The index of the color attachment to retrieve a RenderTarget from.

Returns:
  The RenderTarget attached at the specified index.

unsigned int gameplay::FrameBuffer::getRenderTargetCount | ( |  | ) | const

Returns the current number of render targets attached to this frame buffer.

Returns:
  The number of render targets attached.

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.

Parameters:

  image | The Image to write the current framebuffer's content to.

unsigned int gameplay::FrameBuffer::getWidth | ( |  | ) | const

Gets the width of the frame buffer.

Returns:
  The width of the frame buffer.

bool gameplay::FrameBuffer::isDefault | ( |  | ) | const

Determines whether this is the default frame buffer.

Returns:
  true if this is the default frame buffer, false otherwise.

void gameplay::FrameBuffer::setDepthStencilTarget | ( | DepthStencilTarget * | target | ) |

Set this FrameBuffer's DepthStencilTarget.

Parameters:

  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.

Parameters:

  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.

Parameters:

  target | The Cubemap RenderTarget to set.
  face | The face of the cubemap to target.
  index | The index of the color attachment to set.

All Classes Functions Variables Typedefs Enumerations Enumerator