#include <tb_render_target.hpp>
|
static void | CreateGraphicsContext (void) |
|
static void | DestroyGraphicsContext (void) |
|
The RenderTarget sets up a texture to render to and apply to be rendered after. Just call BindRenderTarget() to start rendering on the texture and UnbindRenderTarget() to go back to normal.
TurtleBrains::Graphics::RenderTarget::RenderTarget |
( |
const PixelSpace & |
targetWidth, |
|
|
const PixelSpace & |
targetHeight, |
|
|
const TargetType & |
targetType = TargetType::Color |
|
) |
| |
|
explicit |
Creates a RenderTarget with specified width and height that can be used to setup and render desired results to the target texture and then applied however later, for full screen effects or other.
TurtleBrains::Graphics::RenderTarget::~RenderTarget |
( |
void |
| ) |
|
void TurtleBrains::Graphics::RenderTarget::BindRenderTarget |
( |
void |
| ) |
const |
Binds the RenderTarget to the context so any other Render calls will get displayed on the texture instead of the frame/back-buffer. Must call UnbindRenderTarget() to return back to the frame/back-buffer.
- Note
- If multiple RenderTargets are used, only one should be bound at any given time, so be sure to unbound before attempting to bind another RenderTarget.
float TurtleBrains::Graphics::RenderTarget::GetAspectRatio |
( |
void |
| ) |
const |
Computes and returns the aspect ratio of the RenderTarget, (width/height) 1920 / 1080 ~= 1.77778.
Retrieves the texture handle of the RenderTarget's depth 'buffer' to be used how one wishes.
- Note
- This will return an invalid handle if the target type is not Depth or ColorAndDepth.
PixelSpace TurtleBrains::Graphics::RenderTarget::GetHeight |
( |
void |
| ) |
const |
Retrieves the height in pixels.
Retrieves the texture handle of the RenderTarget to be applied for full screen or object effects. This texture will be plain white unless rendered to between Bind/Unbind.
- Note
- This will return an invalid handle if the target type is not Color or ColorAndDepth.
PixelSpace TurtleBrains::Graphics::RenderTarget::GetWidth |
( |
void |
| ) |
const |
Retrieves the width in pixels.
bool TurtleBrains::Graphics::RenderTarget::IsTextureValid |
( |
void |
| ) |
const |
Returns true if at some point Bind and Unbind has been called to render to the texture target since creation or a graphics context change.
- Note
- This can be used instead of raw memory to refresh a render target after context change by polling this before it would get rendered.
void TurtleBrains::Graphics::RenderTarget::ManagePixelData |
( |
const bool |
managePixelData | ) |
|
This function will set a flag that will keep or destroy the pixel data after a bind. This will increase memory usage on the system side, as well as incur a performance penalty on UnbindRenderTarget, when the texture data is getting copied, but it allows the render target texture to be reloaded on the fly when the graphics context changes. By default this is disabled; to keep the context change support when disabled, use IsTextureValid() to redraw the texture before it gets used/rendered.
- Note
- If pixel data exists and this is turned off, that pixel data is destroyed. If there is no pixel data when this is turned on, there will still be no pixel data. Call Bind/Unbind to render to the target and create the pixel data.
void TurtleBrains::Graphics::RenderTarget::SetMipmap |
( |
bool |
doMipmaps | ) |
|
Sets whether or not the color and depth textures will generate mipmaps and use mipmap filtering. By default mipmapping is turned OFF.
- Parameters
-
doMipmaps | Set this to true to turn mipmapping on, or false to turn it off. |
- Note
- The toggle will occur on the next bind/unbind instead of immediately.
void TurtleBrains::Graphics::RenderTarget::UnbindRenderTarget |
( |
void |
| ) |
const |
Changes the graphics context to render to the frame/back-buffer back again. This will create the pixel data and load it into the texture that can be retrieved via GetTextureHandle(). The pixel data may remain in system memory (or not) depending on the storage setting; ManagePixelData().