Rose
|
Written as a workaround for an issue in the SDL2 Library. More...
#include <Renderer.h>
Classes | |
class | RendererDestroy |
A functor to destroy an SDL_Renderer. More... | |
Public Member Functions | |
Renderer ()=default | |
Construct an empty renderer. | |
Renderer (const Renderer &renderer)=delete | |
Deleted copy constructor. | |
Renderer (Window &window, int index, Uint32 flags) | |
Construct a renderer associated with a Window. More... | |
Renderer (Renderer &&renderer) noexcept=default | |
Move constructor defaulted. More... | |
Renderer & | operator= (const Renderer &renderer)=delete |
Deleted copy assignment operator. | |
Renderer & | operator= (Renderer &&renderer)=default |
Move assignment operator. More... | |
operator bool () const noexcept | |
Test the renderer. More... | |
auto | get () const |
The the underlying SDL_Renderer* for use with the SDL2 API. More... | |
void | setDrawBlendMode (SDL_BlendMode blendMode) |
Set the SDL_BlendMode on the renderer. More... | |
Texture | createTexture (Size size) |
Create a Texture with the given size. More... | |
void | copyFullTexture (sdl::Texture &source, sdl::Texture &destination) |
Copy source Texture to destination Texture and set the BlendMode on the destination Texture. More... | |
int | renderClear () |
Calls SDL_RenderClear on the renderer. More... | |
void | renderPresent () |
Calls SDL_RenderPresent on the renderer. | |
int | renderCopy (const Texture &texture) |
Calls SDL_RenderCopy to copy the source texture to the current render target. More... | |
int | renderCopy (const Texture &texture, Rectangle dst) |
Calls SDL_RenderCopy to copy the source texture to the current target at a destination Rectangle. More... | |
int | renderCopy (const Texture &texture, Rectangle src, Rectangle dst) |
Calls SDL_RenderCopy to copy the source texture from a source Rectangle to the current target at a destination Rectangle. More... | |
int | renderCopy (GradientTexture &texture, Rectangle dst) |
Render copy a GradientTexture kernel across the destination Rectangle. More... | |
int | renderCopyEx (Texture &texture, Rectangle src, Rectangle dst, double angle, RenderFlip renderFlip, std::optional< Position > point=std::nullopt) const |
Render with extras. More... | |
int | fillRect (Rectangle rectangle, color::RGBA color) |
Calls SDL_RenderFillRect after setting the RenderDrawColor to color. More... | |
int | drawLine (int x0, int y0, int x1, int y1) |
Render a line. More... | |
int | drawPoint (const Position &position, const color::RGBA &rgba) |
template<class C > | |
int | drawLines (C pointsContainer) |
Render lines. More... | |
Protected Types | |
using | RendererPtr = std::unique_ptr< SDL_Renderer, RendererDestroy > |
An SDL_Renderer unique pointer. | |
Protected Member Functions | |
int | popRenderTarget () |
Pop a render target off the stack. More... | |
int | pushRenderTarget (sdl::Texture &texture) |
Set a new render target, and push it onto the stack. More... | |
int | pushRenderTarget () |
Set the render target to the default, and push it onto the stack. More... | |
Protected Attributes | |
RendererPtr | mRenderer {} |
The Renderer. | |
std::stack< SDL_Texture * > | mTargetTextureStack {} |
The stack of render targets. | |
Friends | |
class | RenderTargetGuard |
Written as a workaround for an issue in the SDL2 Library.
https://stackoverflow.com/questions/50415099/sdl-setrendertarget-doesnt-set-the-tartget
rose::sdl::Renderer::Renderer | ( | Window & | window, |
int | index, | ||
Uint32 | flags | ||
) |
|
defaultnoexcept |
Move constructor defaulted.
renderer | The Renderer to move. |
void rose::sdl::Renderer::copyFullTexture | ( | sdl::Texture & | source, |
sdl::Texture & | destination | ||
) |
Copy source Texture to destination Texture and set the BlendMode on the destination Texture.
The function uses RenderTargetGuard to temporarily set the render Target to the destination, calls SDL_RenderCopy to copy the texture, and sets the BlendMode on the destination texture to SDL_BLENDMODE_BLEND.
source | |
destination |
int rose::sdl::Renderer::drawLine | ( | int | x0, |
int | y0, | ||
int | x1, | ||
int | y1 | ||
) |
Render a line.
x0 | Start point X |
y0 | Start point Y |
x1 | End point X |
y1 | End point Y |
|
inline |
Render lines.
The container contains a list of Position objects.
C | The container type. |
pointsContainer | The points container. |
int rose::sdl::Renderer::fillRect | ( | Rectangle | rectangle, |
color::RGBA | color | ||
) |
Calls SDL_RenderFillRect after setting the RenderDrawColor to color.
The existing RenderDrawColor is saved and restored.
rectangle | The rectangle to fill. |
color | The fill color. |
|
inline |
The the underlying SDL_Renderer* for use with the SDL2 API.
|
inlineexplicitnoexcept |
Test the renderer.
Move assignment operator.
renderer | The renderer to assign, this becomes empty after the assignment. |
|
inlineprotected |
Pop a render target off the stack.
If there are none, set the default render target.
The top of the stack is the current render target, unless the default is current in which case the stack will be empty. If the stack has 1 or 0 render targets on it, the renderer is set to the default target.
|
protected |
Set a new render target, and push it onto the stack.
texture | The new render target. |
|
inlineprotected |
Set the render target to the default, and push it onto the stack.
|
inline |
Calls SDL_RenderClear on the renderer.
int rose::sdl::Renderer::renderCopy | ( | const Texture & | texture | ) |
Calls SDL_RenderCopy to copy the source texture to the current render target.
SDL_RenderCopy is called with nullptr for srcrect and dstrect.
texture | The texture to copy. |
Calls SDL_RenderCopy to copy the source texture to the current target at a destination Rectangle.
texture | The sdl::Texture |
dst | The destination RectangleInt |
int rose::sdl::Renderer::renderCopy | ( | GradientTexture & | texture, |
Rectangle | dst | ||
) |
Render copy a GradientTexture kernel across the destination Rectangle.
texture | The GradientTexture. |
dst | The destination Rectangle. |
int rose::sdl::Renderer::renderCopyEx | ( | Texture & | texture, |
Rectangle | src, | ||
Rectangle | dst, | ||
double | angle, | ||
RenderFlip | renderFlip, | ||
std::optional< Position > | point = std::nullopt |
||
) | const |
|
inline |
Set the SDL_BlendMode on the renderer.
blendMode |