Rose
Public Member Functions | Protected Attributes | List of all members
rose::sdl::RenderTargetGuard Class Reference

Store the current render target replacing it with a new render target. More...

#include <Renderer.h>

Collaboration diagram for rose::sdl::RenderTargetGuard:
Collaboration graph
[legend]

Public Member Functions

 RenderTargetGuard ()=delete
 Deleted default constructor.
 
 RenderTargetGuard (const RenderTargetGuard &)=delete
 Deleted copy constructor.
 
 ~RenderTargetGuard () noexcept(false)
 Set the old render target back on the renderer when destroyed.
 
 operator bool () const noexcept
 Test the status of the RenderTargetGuard. More...
 
 RenderTargetGuard (Renderer &renderer, Texture &texture)
 Constructor. More...
 
void clear ()
 Clear the render target so rendering will be sent to the screen backing buffer.
 
int setRenderTarget (Texture &texture)
 Set a new render target without pushing it on the stack. More...
 

Protected Attributes

RenderermRenderer
 The Renderer being guarded.
 
bool popped {false}
 True if the target guard has already been popped off the stack.
 
int status {0}
 The return status from the last SDL API call.
 

Detailed Description

Store the current render target replacing it with a new render target.

When the object is destroyed (by going out of scope) the old render target is restored.

Constructor & Destructor Documentation

◆ RenderTargetGuard()

rose::sdl::RenderTargetGuard::RenderTargetGuard ( Renderer renderer,
Texture texture 
)
inline

Constructor.

Parameters
rendererThe renderer which render target will be managed.
textureThe texture which will become the new render target.

Member Function Documentation

◆ operator bool()

rose::sdl::RenderTargetGuard::operator bool ( ) const
inlineexplicitnoexcept

Test the status of the RenderTargetGuard.

The status is good (true is returned) if the status value returned from the last operation on the Renderer object returned 0.

Returns
True if the last operation succeeded.

◆ setRenderTarget()

int rose::sdl::RenderTargetGuard::setRenderTarget ( Texture texture)

Set a new render target without pushing it on the stack.

This may be used when a number of render target changes are needed in a context block. A RenderTargetGuard is created, calls to setRenderTarget are used to manipulate the render target. When the RenderTargetGuard goes out of scope the original render target is restored.

Parameters
texture
Returns

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