rolmodl
C++ API for the Simple Directmedia Library 2 (SDL2)
|
Renderer class that supports rendering to texture. Use rolmodl::Ren if you do not need support for rendering to texture. More...
#include <Ren.hpp>
Public Member Functions | |
TexRen (Win &win, int i, ren::Flags flags) | |
Initialize a renderer for window win , using the i th rendering driver, with a version of configuration flags that requires support for rendering to texture. More... | |
TexRen (Win &win, ren::Flags flags) | |
Initialize a renderer for window win , with a version of configuration flags that requires support for rendering to texture, using the first rendering driver that supports it. More... | |
TexRen (Win &win, int i) | |
Initialize a renderer for window win , using the i th rendering driver, with a version of the default configuration that requires support for rendering to texture. More... | |
TexRen (Win &win) | |
Initialize a renderer for window win , with a version of the default configuration that requires support for rendering to texture, using the first rendering driver that supports it. More... | |
void | setTarget (RenTex &tex) |
Set the rendering target. More... | |
void | setDefaultTarget () |
Reset the rendering target to the default one. Usually it is the window for which the renderer was created. More... | |
SDL_Texture * | unsafeGetTarget () noexcept |
Query the current rendering target. Unsafe because it returns a raw non-owning pointer to the texture. More... | |
![]() | |
Ren (Win &win, int i, ren::Flags flags) | |
Initialize a renderer for window win , using the i th rendering driver, with configuration flags . More... | |
Ren (Win &win, ren::Flags flags) | |
Initialize a renderer for window win , with configuration flags , using the first rendering driver that supports it. More... | |
Ren (Win &win, int i) | |
Initialize a renderer for window win , using the i th rendering driver, with the default configuration. More... | |
Ren (Win &win) | |
Initialize a renderer for window win , with the default configuration, using the first rendering driver that supports it. More... | |
~Ren () noexcept | |
Free the underlying SDL_Renderer . More... | |
Ren (const Ren &that)=delete | |
Copying rolmodl renderers is not allowed because their lifetime is tied to the underlying SDL_Renderer 's. Use references or some other pointer type instead. | |
Ren (Ren &&that) noexcept | |
Take over the underlying SDL_Renderer of that . | |
Ren & | operator= (const Ren &that)=delete |
Copying rolmodl renderers is not allowed because their lifetime is tied to the underlying SDL_Renderer 's. Use references or some other pointer type instead. | |
Ren & | operator= (Ren &&that) noexcept |
Take over the underlying SDL_Renderer of that . | |
SDL_Renderer * | unsafeRaw () noexcept |
Get the underlying SDL_Renderer* . Unsafe because this value might be nullptr and using it with some SDL functions can lead to rolmodl invariant violation. | |
const SDL_Renderer * | unsafeRaw () const noexcept |
Get the underlying SDL_Renderer* in a const context. Unsafe because this value might be nullptr and using it with some SDL functions can lead to rolmodl invariant violation. | |
void | clear () |
Paint over the entire rendering target with the current color. More... | |
void | present () noexcept |
Push the backbuffer to screen, displaying any changes made since the last present . This operation invalidates the rendering buffer and it must be cleared with rolmodl::Ren::clear. More... | |
void | drawTex (Tex &tex) |
Copy the entire texture tex to fill the entire rendering target. More... | |
void | drawTex (Tex &tex, const SrcRectWH src) |
Copy the part of texture tex specified by the source rectangle src to fill the entire rendering target. More... | |
void | drawTex (Tex &tex, const SrcRectXY src) |
Copy the part of texture tex specified by the source rectangle src to fill the entire rendering target. More... | |
void | drawTex (Tex &tex, const DstRectWH dst) |
Copy the entire texture tex to fill the part of the rendering target specified by the destination rectangle dst . More... | |
void | drawTex (Tex &tex, const DstRectXY dst) |
Copy the entire texture tex to fill the part of the rendering target specified by the destination rectangle dst . More... | |
void | drawTex (Tex &tex, const SrcRectWH src, const DstRectWH dst) |
Copy the part of texture tex specified by the source rectangle src to fill the part of the rendering target specified by the destination rectangle dst . More... | |
void | drawTex (Tex &tex, const SrcRectWH src, const DstRectXY dst) |
Copy the part of texture tex specified by the source rectangle src to fill the part of the rendering target specified by the destination rectangle dst . More... | |
void | drawTex (Tex &tex, const SrcRectXY src, const DstRectWH dst) |
Copy the part of texture tex specified by the source rectangle src to fill the part of the rendering target specified by the destination rectangle dst . More... | |
void | drawTex (Tex &tex, const SrcRectXY src, const DstRectXY dst) |
Copy the part of texture tex specified by the source rectangle src to fill the part of the rendering target specified by the destination rectangle dst . More... | |
void | drawTex (Tex &tex, const Flip flip) |
Copy the entire texture tex to fill the entire rendering target, respecting the flipping configuration flip . More... | |
void | drawTex (Tex &tex, const double rot, const Flip flip=Flip()) |
Copy the entire texture tex to fill the entire rendering target, rotating it by rot radian around its center, respecting the flipping configuration flip . More... | |
void | drawTex (Tex &tex, const double rot, const geom::Pos rotCenter, const Flip flip=Flip()) |
Copy the entire texture tex to fill the entire rendering target, rotating it by rot radian around rotCenter , respecting the flipping configuration flip . More... | |
void | drawTex (Tex &tex, const SrcRectWH src, const Flip flip) |
Copy the part of texture tex specified by the source rectangle src to fill the entire rendering target, respecting the flipping configuration flip . More... | |
void | drawTex (Tex &tex, const SrcRectXY src, const Flip flip) |
Copy the part of texture tex specified by the source rectangle src to fill the entire rendering target, respecting the flipping configuration flip . More... | |
void | drawTex (Tex &tex, const SrcRectWH src, const double rot, const Flip flip=Flip()) |
Copy the part of texture tex specified by the source rectangle src to fill the entire rendering target, rotating it by rot radian around its center, respecting the flipping configuration flip . More... | |
void | drawTex (Tex &tex, const SrcRectXY src, const double rot, const Flip flip=Flip()) |
Copy the part of texture tex specified by the source rectangle src to fill the entire rendering target, rotating it by rot radian around its center, respecting the flipping configuration flip . More... | |
void | drawTex (Tex &tex, const SrcRectWH src, const double rot, const geom::Pos rotCenter, const Flip flip=Flip()) |
Copy the part of texture tex specified by the source rectangle src to fill the entire rendering target, rotating it by rot radian around rotCenter , respecting the flipping configuration flip . More... | |
void | drawTex (Tex &tex, const SrcRectXY src, const double rot, const geom::Pos rotCenter, const Flip flip=Flip()) |
Copy the part of texture tex specified by the source rectangle src to fill the entire rendering target, rotating it by rot radian around rotCenter , respecting the flipping configuration flip . More... | |
void | drawTex (Tex &tex, const DstRectWH dst, const Flip flip) |
Copy the entire texture tex to fill the part of the rendering target specified by the destination rectangle dst , respecting the flipping configuration flip . More... | |
void | drawTex (Tex &tex, const DstRectXY dst, const Flip flip) |
Copy the entire texture tex to fill the part of the rendering target specified by the destination rectangle dst , respecting the flipping configuration flip . More... | |
void | drawTex (Tex &tex, const DstRectWH dst, const double rot, const Flip flip=Flip()) |
Copy the entire texture tex to fill the part of the rendering target specified by the destination rectangle dst , rotating it by rot radian around its center, respecting the flipping configuration flip . More... | |
void | drawTex (Tex &tex, const DstRectXY dst, const double rot, const Flip flip=Flip()) |
Copy the entire texture tex to fill the part of the rendering target specified by the destination rectangle dst , rotating it by rot radian around its center, respecting the flipping configuration flip . More... | |
void | drawTex (Tex &tex, const DstRectWH dst, const double rot, const geom::Pos rotCenter, const Flip flip=Flip()) |
Copy the entire texture tex to fill the part of the rendering target specified by the destination rectangle dst , rotating it by rot radian around rotCenter , respecting the flipping configuration flip . More... | |
void | drawTex (Tex &tex, const DstRectXY dst, const double rot, const geom::Pos rotCenter, const Flip flip=Flip()) |
Copy the entire texture tex to fill the part of the rendering target specified by the destination rectangle dst , rotating it by rot radian around rotCenter , respecting the flipping configuration flip . More... | |
void | drawTex (Tex &tex, const SrcRectWH src, const DstRectWH dst, const Flip flip) |
Copy the part of texture tex specified by the source rectangle src to fill the part of the rendering target specified by the destination rectangle dst , respecting the flipping configuration flip . More... | |
void | drawTex (Tex &tex, const SrcRectWH src, const DstRectXY dst, const Flip flip) |
Copy the part of texture tex specified by the source rectangle src to fill the part of the rendering target specified by the destination rectangle dst , respecting the flipping configuration flip . More... | |
void | drawTex (Tex &tex, const SrcRectXY src, const DstRectWH dst, const Flip flip) |
Copy the part of texture tex specified by the source rectangle src to fill the part of the rendering target specified by the destination rectangle dst , respecting the flipping configuration flip . More... | |
void | drawTex (Tex &tex, const SrcRectXY src, const DstRectXY dst, const Flip flip) |
Copy the part of texture tex specified by the source rectangle src to fill the part of the rendering target specified by the destination rectangle dst , respecting the flipping configuration flip . More... | |
void | drawTex (Tex &tex, const SrcRectWH src, const DstRectWH dst, const double rot, const Flip flip=Flip()) |
Copy the part of texture tex specified by the source rectangle src to fill the part of the rendering target specified by the destination rectangle dst , rotating it by rot radian around its center, respecting the flipping configuration flip . More... | |
void | drawTex (Tex &tex, const SrcRectWH src, const DstRectXY dst, const double rot, const Flip flip=Flip()) |
Copy the part of texture tex specified by the source rectangle src to fill the part of the rendering target specified by the destination rectangle dst , rotating it by rot radian around its center, respecting the flipping configuration flip . More... | |
void | drawTex (Tex &tex, const SrcRectXY src, const DstRectWH dst, const double rot, const Flip flip=Flip()) |
Copy the part of texture tex specified by the source rectangle src to fill the part of the rendering target specified by the destination rectangle dst , rotating it by rot radian around its center, respecting the flipping configuration flip . More... | |
void | drawTex (Tex &tex, const SrcRectXY src, const DstRectXY dst, const double rot, const Flip flip=Flip()) |
Copy the part of texture tex specified by the source rectangle src to fill the part of the rendering target specified by the destination rectangle dst , rotating it by rot radian around its center, respecting the flipping configuration flip . More... | |
void | drawTex (Tex &tex, const SrcRectWH src, const DstRectWH dst, const double rot, const geom::Pos rotCenter, const Flip flip=Flip()) |
Copy the part of texture tex specified by the source rectangle src to fill the part of the rendering target specified by the destination rectangle dst , rotating it by rot radian around rotCenter , respecting the flipping configuration flip . More... | |
void | drawTex (Tex &tex, const SrcRectWH src, const DstRectXY dst, const double rot, const geom::Pos rotCenter, const Flip flip=Flip()) |
Copy the part of texture tex specified by the source rectangle src to fill the part of the rendering target specified by the destination rectangle dst , rotating it by rot radian around rotCenter , respecting the flipping configuration flip . More... | |
void | drawTex (Tex &tex, const SrcRectXY src, const DstRectWH dst, const double rot, const geom::Pos rotCenter, const Flip flip=Flip()) |
Copy the part of texture tex specified by the source rectangle src to fill the part of the rendering target specified by the destination rectangle dst , rotating it by rot radian around rotCenter , respecting the flipping configuration flip . More... | |
void | drawTex (Tex &tex, const SrcRectXY src, const DstRectXY dst, const double rot, const geom::Pos rotCenter, const Flip flip=Flip()) |
Copy the part of texture tex specified by the source rectangle src to fill the part of the rendering target specified by the destination rectangle dst , rotating it by rot radian around rotCenter , respecting the flipping configuration flip . More... | |
void | drawLine (const geom::Pos a, const geom::Pos b) |
Draw a line from point a to point b with the drawing color. More... | |
void | drawPoint (const geom::Pos p) |
Set the pixel at point p to the drawing color. More... | |
void | drawRect (const geom::RectWH r) |
Draw the outline of the width-height rect r with the drawing color. More... | |
void | drawRect (const geom::RectXY r) |
Draw the outline of the xy-rect rect r with the drawing color. More... | |
void | fillRect (const geom::RectWH r) |
Fill the width-height rect r with the drawing color. More... | |
void | fillRect (const geom::RectXY r) |
Fill the xy-rect rect r with the drawing color. More... | |
void | outlineScreen () |
Draw an outline around the rendering target with the drawing color. More... | |
void | fillScreen () |
Fill the rendering target with the drawing color. More... | |
std::optional< geom::RectWH > | clipRect () noexcept |
Get the clipping rectangle. std::nullopt is returned if the clipping rectangle has not been set. More... | |
void | setClipRect (const geom::RectWH r) |
Set the clipping rectangle to r . More... | |
void | setClipRect (const geom::RectXY r) |
Set the clipping rectangle to r . More... | |
void | disableClip () |
Unset the clipping rectangle. More... | |
bool | isClipOn () noexcept |
Query whether the clipping rectangle has been set. More... | |
std::optional< geom::Size > | logicalSize () noexcept |
Query the device-independent resolution. More... | |
void | setLogicalSize (const geom::Size s) |
Set the device-independent resolution to s . More... | |
geom::Size | getRealSize () |
Query the target resolution in device pixels. More... | |
RenScale | scale () noexcept |
Query the rendering scaling factors. More... | |
void | setScale (const RenScale s) |
Set the rendering scaling factors to s . More... | |
geom::RectWH | viewport () noexcept |
Query the subarea of the target used for drawing. More... | |
void | setViewport (const geom::RectWH r) |
Set the subarea of the target used for drawing to the rectangle r . More... | |
BlendMode | getBlendMode () |
Get the blending mode used for draw operations. Textures have their own separate belnding mode. More... | |
void | setBlendMode (const BlendMode m) |
Set the blending mode used for draw operations to m . Does not effect how textures are blended. More... | |
RGBA | color () |
Query the current drawing color. More... | |
void | setColor (const RGBA c) |
Set the drawing color to c . More... | |
Renderer class that supports rendering to texture. Use rolmodl::Ren if you do not need support for rendering to texture.
Wrapper around SDL_Renderer
.
The renderer managed by this class always supports rendering to texture, or the constructor will throw an rolmodl::sdlexception.
rolmodl::TexRen::TexRen | ( | Win & | win, |
int | i, | ||
ren::Flags | flags | ||
) |
Initialize a renderer for window win
, using the i
th rendering driver, with a version of configuration flags
that requires support for rendering to texture.
rolmodl::sdlexception | SDL reported an error. |
rolmodl::TexRen::TexRen | ( | Win & | win, |
ren::Flags | flags | ||
) |
Initialize a renderer for window win
, with a version of configuration flags
that requires support for rendering to texture, using the first rendering driver that supports it.
rolmodl::sdlexception | SDL reported an error. |
rolmodl::TexRen::TexRen | ( | Win & | win, |
int | i | ||
) |
Initialize a renderer for window win
, using the i
th rendering driver, with a version of the default configuration that requires support for rendering to texture.
rolmodl::sdlexception | SDL reported an error. |
|
explicit |
Initialize a renderer for window win
, with a version of the default configuration that requires support for rendering to texture, using the first rendering driver that supports it.
rolmodl::sdlexception | SDL reported an error. |
void rolmodl::TexRen::setTarget | ( | RenTex & | tex | ) |
Set the rendering target.
Definition at line 360 of file Ren.cpp.
References rolmodl::detail::throwOnErr(), and rolmodl::Ren::unsafeRaw().
void rolmodl::TexRen::setDefaultTarget | ( | ) |
Reset the rendering target to the default one. Usually it is the window for which the renderer was created.
Definition at line 363 of file Ren.cpp.
References rolmodl::detail::throwOnErr(), and rolmodl::Ren::unsafeRaw().
|
noexcept |
Query the current rendering target. Unsafe because it returns a raw non-owning pointer to the texture.
Definition at line 367 of file Ren.cpp.
References rolmodl::Ren::unsafeRaw().