overview wiki api reference download
 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:
gameplay::Ref

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)
RenderTargetgetRenderTarget (unsigned int index=0) const
unsigned int getRenderTargetCount () const
void setDepthStencilTarget (DepthStencilTarget *target)
DepthStencilTargetgetDepthStencilTarget () const
bool isDefault () const
FrameBufferbind ()

Static Public Member Functions

static FrameBuffercreate (const char *id)
static FrameBuffercreate (const char *id, unsigned int width, unsigned int height)
static FrameBuffergetFrameBuffer (const char *id)
static unsigned int getMaxRenderTargets ()
static ImagecreateScreenshot (Image::Format format=Image::RGBA)
static void getScreenshot (Image *image)
static FrameBufferbindDefault ()
static FrameBuffergetCurrent ()

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

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.

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:
idThe 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:
idThe ID of the new FrameBuffer. Uniqueness is recommended but not enforced.
widthThe width of the RenderTarget to be created and attached.
heightThe 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:
formatThe format the Image should be in.
Returns:
A screenshot of the current framebuffer's content.

Gets the currently bound FrameBuffer.

Returns:
The currently bound FrameBuffer.
static FrameBuffer* gameplay::FrameBuffer::getFrameBuffer ( const char *  id) [static]

Get a named FrameBuffer from its ID.

Parameters:
idThe 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:
indexThe index of the color attachment to retrieve a RenderTarget from.
Returns:
The RenderTarget attached at the specified index.

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

Determines whether this is the default frame buffer.

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

Set this FrameBuffer's DepthStencilTarget.

Parameters:
targetThe 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:
targetThe 2D RenderTarget to set.
indexThe 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:
targetThe Cubemap RenderTarget to set.
faceThe face of the cubemap to target.
indexThe index of the color attachment to set.
 All Classes Functions Variables Typedefs Enumerations Enumerator