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

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

#include <GraphicsModel.h>

Collaboration diagram for rose::gm::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 (Context &context, Texture &texture)
 Constructor. More...
 
int setRenderTarget (Texture &texture)
 Set a new render target without pushing it on the stack. More...
 

Protected Attributes

ContextmContext
 The Context being guarded.
 
bool popped {false}
 True if the target guard has already been popped off the stack.
 
SDL_Texture * mLastTexture {nullptr}
 Save the current render target here.
 
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::gm::RenderTargetGuard::RenderTargetGuard ( Context context,
Texture texture 
)

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::gm::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 Context object returned 0.

Returns
True if the last operation succeeded.

◆ setRenderTarget()

int rose::gm::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: