FPLBase
An open source project by
FPL.
|
Abstracts a surface that can be rendered to. More...
#include <render_target.h>
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... | |
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.
texture_number | The index of the texture to make active. |
|
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.
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.
dimensions | The 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.
dimensions | The dimensions of the render target. |
format | The OpenGL format of the generated texture. |
useDepthBuffer | Create a depth buffer used by the render target. |
|
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.
|
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.
|
static |
Gets the RenderTarget that corresponds to the screen.
renderer | The renderer object to use. |
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.