TurtleBrains  0.3.1
High quality, portable, C++ framework for rapid 2D game development.
TurtleBrains::Graphics::RenderTarget Class Reference

#include <tb_render_target.h>

Inheritance diagram for TurtleBrains::Graphics::RenderTarget:
TurtleBrains::Core::Noncopyable

Public Member Functions

 RenderTarget (const PixelSpace &targetWidth, const PixelSpace &targetHeight)
 
 ~RenderTarget (void)
 
void BindRenderTarget (void) const
 
void UnbindRenderTarget (void) const
 
tbGraphics::TextureHandle GetTextureHandle (void) const
 
PixelSpace GetWidth (void) const
 
PixelSpace GetHeight (void) const
 
float GetAspectRatio (void) const
 

Detailed Description

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.

Constructor & Destructor Documentation

TurtleBrains::Graphics::RenderTarget::RenderTarget ( const PixelSpace targetWidth,
const PixelSpace targetHeight 
)

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  )

Cleans up all resources used by the RenderTarget.

Member Function Documentation

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.

PixelSpace TurtleBrains::Graphics::RenderTarget::GetHeight ( void  ) const

Retrieves the height in pixels.

tbGraphics::TextureHandle TurtleBrains::Graphics::RenderTarget::GetTextureHandle ( void  ) const

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.

PixelSpace TurtleBrains::Graphics::RenderTarget::GetWidth ( void  ) const

Retrieves the width in pixels.

void TurtleBrains::Graphics::RenderTarget::UnbindRenderTarget ( void  ) const

Changes the graphics context to render to the frame/back-buffer back again.