FPLBase
An open source project by FPL.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
fplbase::RenderTarget Class Reference

Abstracts a surface that can be rendered to. More...

#include <render_target.h>

Detailed Description

Abstracts a surface that can be rendered to.

Calling SetAsRenderTarget() will cause all subsequent draw calls to be drawn onto the RenderTarget instead of to the screen buffer.

Public Member Functions

void Initialize (const mathfu::vec2i &dimensions)
 Initialize a render target of the provided dimensions. More...
 
void Initialize (const mathfu::vec2i &dimensions, RenderTargetFormat format, bool useDepthBuffer)
 Initialize a render target of the provided dimensions. More...
 
void Delete ()
 Deletes the associated opengl resources associated with the RenderTarget.
 
void SetAsRenderTarget () const
 Sets the RenderTarget as the active render target. More...
 
void BindAsTexture (int texture_number) const
 Binds the texture associated with this rendertarget as the active texture. More...
 
bool IsTexture () const
 Checks if this rendertarget refer to an off-screen texture. More...
 
TextureHandle GetTextureId () const
 Gets the TextureId associated with the RenderTarget, assuming that it is texture-based. More...
 
bool initialized () const
 Checks if the RenderTarget has been initialized. More...
 

Static Public Member Functions

static RenderTarget ScreenRenderTarget (Renderer &renderer)
 Gets the RenderTarget that corresponds to the screen. More...
 

Member Function Documentation

void fplbase::RenderTarget::BindAsTexture ( int  texture_number) const

Binds the texture associated with this rendertarget as the active texture.

Primarily useful when rendering the RenderTarget's texture as part of a mesh. Throws an assert if the RenderTarget does not have a texture.

Parameters
texture_numberThe index of the texture to make active.
TextureHandle fplbase::RenderTarget::GetTextureId ( ) const
inline

Gets the TextureId associated with the RenderTarget, assuming that it is texture-based.

Throws an assert if you try to call GetTextureId on a RenderTarget that doesn't have a texture backing it, such as the screen's display buffer.

Returns
Returns the TextureId associated with the RenderTarget.
void fplbase::RenderTarget::Initialize ( const mathfu::vec2i &  dimensions)

Initialize a render target of the provided dimensions.

Defaults the format to GL_UNSIGNED_BYTE, using a depth buffer.

Parameters
dimensionsThe dimensions of the render target.
void fplbase::RenderTarget::Initialize ( const mathfu::vec2i &  dimensions,
RenderTargetFormat  format,
bool  useDepthBuffer 
)

Initialize a render target of the provided dimensions.

Parameters
dimensionsThe dimensions of the render target.
formatThe OpenGL format of the generated texture.
useDepthBufferCreate a depth buffer used by the render target.
bool fplbase::RenderTarget::initialized ( ) const
inline

Checks if the RenderTarget has been initialized.

Returns true if this RenderTarget has been initialized and is ready to use. Returns false if has not yet been initialized, failed initalization, or has been deleted. Trying to use an uninitialized RenderTarget will generally cause errors or asserts.

Returns true if it has been initialized, false otherwise.

bool fplbase::RenderTarget::IsTexture ( ) const
inline

Checks if this rendertarget refer to an off-screen texture.

This is important because rendertargets that aren't texture-based will assert if you try to bind them as texture or access their textureId.

Returns
Returns true if this rendertarget refers to an off-screen texture, and false if it refers to the screen itself.
static RenderTarget fplbase::RenderTarget::ScreenRenderTarget ( Renderer renderer)
static

Gets the RenderTarget that corresponds to the screen.

Parameters
rendererThe renderer object to use.
Returns
Returns the RenderTarget that corresponds to the screen.
void fplbase::RenderTarget::SetAsRenderTarget ( ) const

Sets the RenderTarget as the active render target.

All subsequent openGL draw calls will render to this RenderTarget instead of wherever they were going before.


The documentation for this class was generated from the following file: