libSDL2pp
C++ bindings/wrapper for SDL2
|
2D rendering context More...
#include <SDL2pp/Renderer.hh>
Public Member Functions | |
Renderer (SDL_Renderer *renderer) | |
Construct from existing SDL_Renderer structure. | |
Renderer (Window &window, int index, Uint32 flags) | |
Create renderer. | |
virtual | ~Renderer () |
Destructor. | |
Renderer (Renderer &&other) noexcept | |
Move constructor. | |
Renderer & | operator= (Renderer &&other) noexcept |
Move assignment operator. | |
Renderer (const Renderer &other)=delete | |
Deleted copy constructor. | |
Renderer & | operator= (const Renderer &other)=delete |
Deleted assignment operator. | |
SDL_Renderer * | Get () const |
Get pointer to managed SDL_Renderer structure. | |
Renderer & | Present () |
Update the screen with any rendering performed since the previous call. | |
Renderer & | Clear () |
Clear the current rendering target with the drawing color. | |
void | GetInfo (SDL_RendererInfo &info) |
Get information about a rendering context. | |
Renderer & | Copy (Texture &texture, const Optional< Rect > &srcrect=NullOpt, const Optional< Rect > &dstrect=NullOpt) |
Copy a portion of the texture to the current rendering target. | |
Renderer & | Copy (Texture &texture, const Optional< Rect > &srcrect, const Point &dstpoint) |
Copy a portion of the texture to the current rendering target (preserve texture dimensions) | |
Renderer & | Copy (Texture &texture, const Optional< Rect > &srcrect, const Optional< Rect > &dstrect, double angle, const Optional< Point > ¢er=NullOpt, int flip=0) |
Copy a portion of the texture to the current rendering target with optional rotating or flipping. | |
Renderer & | Copy (Texture &texture, const Optional< Rect > &srcrect, const SDL2pp::Point &dstpoint, double angle, const Optional< Point > ¢er=NullOpt, int flip=0) |
Copy a portion of the texture to the current rendering target with optional rotating or flipping (preserve texture dimensions) | |
Renderer & | FillCopy (Texture &texture, const Optional< Rect > &srcrect=NullOpt, const Optional< Rect > &dstrect=NullOpt, const Point &offset=Point(0, 0), int flip=0) |
Fill the target with repeated source texture. | |
Renderer & | SetDrawColor (Uint8 r=0, Uint8 g=0, Uint8 b=0, Uint8 a=255) |
Set color user for drawing operations. | |
Renderer & | SetDrawColor (const Color &color) |
Set color user for drawing operations. | |
Renderer & | SetTarget () |
Set current render target to default. | |
Renderer & | SetTarget (Texture &texture) |
Set current render target to specified texture. | |
Renderer & | SetDrawBlendMode (SDL_BlendMode blendMode=SDL_BLENDMODE_NONE) |
Set the blend mode used for drawing operations. | |
Renderer & | DrawPoint (int x, int y) |
Draw a point on the current rendering target. | |
Renderer & | DrawPoint (const Point &p) |
Draw a point on the current rendering target. | |
Renderer & | DrawPoints (const Point *points, int count) |
Draw multiple points on the current rendering target. | |
Renderer & | DrawLine (int x1, int y1, int x2, int y2) |
Draw a line on the current rendering target. | |
Renderer & | DrawLine (const Point &p1, const Point &p2) |
Draw a line on the current rendering target. | |
Renderer & | DrawLines (const Point *points, int count) |
Draw a polyline on the current rendering target. | |
Renderer & | DrawRect (int x1, int y1, int x2, int y2) |
Draw a rectangle on the current rendering target. | |
Renderer & | DrawRect (const Point &p1, const Point &p2) |
Draw a rectangle on the current rendering target. | |
Renderer & | DrawRect (const Rect &r) |
Draw a rectangle on the current rendering target. | |
Renderer & | DrawRects (const Rect *rects, int count) |
Draw multiple rectangles on the current rendering target. | |
Renderer & | FillRect (int x1, int y1, int x2, int y2) |
Fill a rectangle on the current rendering target. | |
Renderer & | FillRect (const Point &p1, const Point &p2) |
Fill a rectangle on the current rendering target. | |
Renderer & | FillRect (const Rect &r) |
Fill a rectangle on the current rendering target. | |
Renderer & | FillRects (const Rect *rects, int count) |
Fill multiple rectangles on the current rendering target. | |
void | ReadPixels (const Optional< Rect > &rect, Uint32 format, void *pixels, int pitch) |
Read pixels from the current rendering target. | |
Renderer & | SetClipRect (const Optional< Rect > &rect=NullOpt) |
Set the clipping rectangle for rendering. | |
Renderer & | SetLogicalSize (int w, int h) |
Set a device independent resolution for rendering. | |
Renderer & | SetScale (float scaleX, float scaleY) |
Set the drawing scale for rendering on the current target. | |
Renderer & | SetViewport (const Optional< Rect > &rect=NullOpt) |
Set the drawing area for rendering on the current target. | |
bool | TargetSupported () const |
Determine whether a window supports the use of render targets. | |
Optional< Rect > | GetClipRect () const |
Get the clip rectangle for the current target. | |
Point | GetLogicalSize () const |
Get device independent resolution for rendering. | |
int | GetLogicalWidth () const |
Get device independent width resolution for rendering. | |
int | GetLogicalHeight () const |
Get device independent width resolution for rendering. | |
void | GetScale (float &scalex, float &scaley) const |
Get the drawing scale for the current target. | |
float | GetXScale () const |
Get the drawing scale for the current target. | |
float | GetYScale () const |
Get the drawing scale for the current target. | |
Rect | GetViewport () const |
Get the drawing area for the current target. | |
SDL_BlendMode | GetDrawBlendMode () const |
Get the blend mode used for drawing operations. | |
Color | GetDrawColor () const |
Get the additional color value multiplied into render copy operations. | |
void | GetDrawColor (Uint8 &r, Uint8 &g, Uint8 &b, Uint8 &a) const |
Get the additional color value multiplied into render copy operations. | |
Point | GetOutputSize () const |
Get the output size of a rendering context. | |
int | GetOutputWidth () const |
Get the output width of a rendering context. | |
int | GetOutputHeight () const |
Get the output height of a rendering context. | |
2D rendering context
|
explicit |
Construct from existing SDL_Renderer structure.
[in] | renderer | Existing SDL_Renderer to manage |
SDL2pp::Renderer::Renderer | ( | Window & | window, |
int | index, | ||
Uint32 | flags | ||
) |
Create renderer.
[in] | window | Window where rendering is displayed |
[in] | index | Index of the rendering driver to initialize, or -1 to initialize the first one supporting the requested flags |
[in] | flags | 0 or more SDL_RendererFlags OR'ed together |
SDL2pp::Exception |
|
virtual |
Destructor.
|
noexcept |
Move constructor.
[in] | other | SDL2pp::Renderer object to move data from |
|
delete |
Deleted copy constructor.
This class is not copyable
Renderer & SDL2pp::Renderer::Clear | ( | ) |
Clear the current rendering target with the drawing color.
SDL2pp::Exception |
Renderer & SDL2pp::Renderer::Copy | ( | Texture & | texture, |
const Optional< Rect > & | srcrect, | ||
const Optional< Rect > & | dstrect, | ||
double | angle, | ||
const Optional< Point > & | center = NullOpt , |
||
int | flip = 0 |
||
) |
Copy a portion of the texture to the current rendering target with optional rotating or flipping.
[in] | texture | Source texture |
[in] | srcrect | Source rectangle, NullOpt for the entire texture |
[in] | dstrect | Destination rectangle, NullOpt for the entire rendering target |
[in] | angle | Angle in degrees that indicates the rotation that will be applied to dstrect |
[in] | center | Point indicating the point around which dstrect will be rotated (NullOpt to rotate around dstrect center) |
[in] | flip | SDL_RendererFlip value stating which flipping actions should be performed on the texture |
SDL2pp::Exception |
Renderer & SDL2pp::Renderer::Copy | ( | Texture & | texture, |
const Optional< Rect > & | srcrect, | ||
const Point & | dstpoint | ||
) |
Copy a portion of the texture to the current rendering target (preserve texture dimensions)
[in] | texture | Source texture |
[in] | srcrect | Source rectangle, NullOpt for the entire texture |
[in] | dstpoint | Target point for source top left corner |
SDL2pp::Exception |
Renderer & SDL2pp::Renderer::Copy | ( | Texture & | texture, |
const Optional< Rect > & | srcrect, | ||
const SDL2pp::Point & | dstpoint, | ||
double | angle, | ||
const Optional< Point > & | center = NullOpt , |
||
int | flip = 0 |
||
) |
Copy a portion of the texture to the current rendering target with optional rotating or flipping (preserve texture dimensions)
[in] | texture | Source texture |
[in] | srcrect | Source rectangle, NullOpt for the entire texture |
[in] | dstpoint | Target point for source top left corner |
[in] | angle | Angle in degrees that indicates the rotation that will be applied to dstrect |
[in] | center | Point indicating the point around which dstrect will be rotated (NullOpt to rotate around dstrect center) |
[in] | flip | SDL_RendererFlip value stating which flipping actions should be performed on the texture |
SDL2pp::Exception |
Renderer & SDL2pp::Renderer::Copy | ( | Texture & | texture, |
const Optional< Rect > & | srcrect = NullOpt , |
||
const Optional< Rect > & | dstrect = NullOpt |
||
) |
Copy a portion of the texture to the current rendering target.
[in] | texture | Source texture |
[in] | srcrect | Source rectangle, NullOpt for the entire texture |
[in] | dstrect | Destination rectangle, NullOpt for the entire rendering target |
SDL2pp::Exception |
Draw a line on the current rendering target.
[in] | p1 | Coordinates of the start point |
[in] | p2 | Coordinates of the end point |
SDL2pp::Exception |
Renderer & SDL2pp::Renderer::DrawLine | ( | int | x1, |
int | y1, | ||
int | x2, | ||
int | y2 | ||
) |
Draw a line on the current rendering target.
[in] | x1 | X coordinate of the start point |
[in] | y1 | Y coordinate of the start point |
[in] | x2 | X coordinate of the end point |
[in] | y2 | Y coordinate of the end point |
SDL2pp::Exception |
Draw a polyline on the current rendering target.
[in] | points | Array of coordinates of points along the polyline |
[in] | count | Number of points to draw count-1 polyline segments |
SDL2pp::Exception |
Draw a point on the current rendering target.
[in] | p | Coordinates of the point |
SDL2pp::Exception |
Renderer & SDL2pp::Renderer::DrawPoint | ( | int | x, |
int | y | ||
) |
Draw a point on the current rendering target.
[in] | x | X coordinate of the point |
[in] | y | Y coordinate of the point |
SDL2pp::Exception |
Draw multiple points on the current rendering target.
[in] | points | Array of coordinates of points to draw |
[in] | count | Number of points to draw |
SDL2pp::Exception |
Draw a rectangle on the current rendering target.
[in] | p1 | Coordinates of the start corner |
[in] | p2 | Coordinates of the end corner |
SDL2pp::Exception |
Draw a rectangle on the current rendering target.
[in] | r | Rectangle to draw |
SDL2pp::Exception |
Renderer & SDL2pp::Renderer::DrawRect | ( | int | x1, |
int | y1, | ||
int | x2, | ||
int | y2 | ||
) |
Draw a rectangle on the current rendering target.
[in] | x1 | X coordinate of the start corner |
[in] | y1 | Y coordinate of the start corner |
[in] | x2 | X coordinate of the end corner |
[in] | y2 | Y coordinate of the end corner |
SDL2pp::Exception |
Draw multiple rectangles on the current rendering target.
[in] | rects | Array of rectangles to draw |
[in] | count | Number of rectangles |
SDL2pp::Exception |
Renderer & SDL2pp::Renderer::FillCopy | ( | Texture & | texture, |
const Optional< Rect > & | srcrect = NullOpt , |
||
const Optional< Rect > & | dstrect = NullOpt , |
||
const Point & | offset = Point(0, 0) , |
||
int | flip = 0 |
||
) |
Fill the target with repeated source texture.
[in] | texture | Source texture |
[in] | srcrect | Source rectangle, NullOpt for the entire texture |
[in] | dstrect | Destination rectangle, NullOpt for the entire rendering target |
[in] | offset | Offset of tiled texture in pixels relative to dstrect |
[in] | flip | SDL_RendererFlip value stating which flipping actions should be performed on the texture |
SDL2pp::Exception |
Fill a rectangle on the current rendering target.
[in] | p1 | Coordinates of the start corner |
[in] | p2 | Coordinates of the end corner |
SDL2pp::Exception |
Fill a rectangle on the current rendering target.
[in] | r | Rectangle to draw |
SDL2pp::Exception |
Renderer & SDL2pp::Renderer::FillRect | ( | int | x1, |
int | y1, | ||
int | x2, | ||
int | y2 | ||
) |
Fill a rectangle on the current rendering target.
[in] | x1 | X coordinate of the start corner |
[in] | y1 | Y coordinate of the start corner |
[in] | x2 | X coordinate of the end corner |
[in] | y2 | Y coordinate of the end corner |
SDL2pp::Exception |
Fill multiple rectangles on the current rendering target.
[in] | rects | Array of rectangles to draw |
[in] | count | Number of rectangles |
SDL2pp::Exception |
SDL_Renderer * SDL2pp::Renderer::Get | ( | ) | const |
Get pointer to managed SDL_Renderer structure.
Optional< Rect > SDL2pp::Renderer::GetClipRect | ( | ) | const |
Get the clip rectangle for the current target.
SDL_BlendMode SDL2pp::Renderer::GetDrawBlendMode | ( | ) | const |
Get the blend mode used for drawing operations.
SDL2pp::Exception |
Color SDL2pp::Renderer::GetDrawColor | ( | ) | const |
Get the additional color value multiplied into render copy operations.
SDL2pp::Exception |
void SDL2pp::Renderer::GetDrawColor | ( | Uint8 & | r, |
Uint8 & | g, | ||
Uint8 & | b, | ||
Uint8 & | a | ||
) | const |
Get the additional color value multiplied into render copy operations.
[out] | r | Variable to be filled in with red value used to draw on the rendering target |
[out] | g | Variable to be filled in with green value used to draw on the rendering target |
[out] | b | Variable to be filled in with blue value used to draw on the rendering target |
[out] | a | Variable to be filled in with alpha value used to draw on the rendering target |
SDL2pp::Exception |
void SDL2pp::Renderer::GetInfo | ( | SDL_RendererInfo & | info | ) |
Get information about a rendering context.
[out] | info | SDL_RendererInfo structure to be filled with information about the current renderer |
SDL2pp::Exception |
int SDL2pp::Renderer::GetLogicalHeight | ( | ) | const |
Get device independent width resolution for rendering.
Point SDL2pp::Renderer::GetLogicalSize | ( | ) | const |
Get device independent resolution for rendering.
int SDL2pp::Renderer::GetLogicalWidth | ( | ) | const |
Get device independent width resolution for rendering.
int SDL2pp::Renderer::GetOutputHeight | ( | ) | const |
Point SDL2pp::Renderer::GetOutputSize | ( | ) | const |
Get the output size of a rendering context.
SDL2pp::Exception |
int SDL2pp::Renderer::GetOutputWidth | ( | ) | const |
void SDL2pp::Renderer::GetScale | ( | float & | scalex, |
float & | scaley | ||
) | const |
Get the drawing scale for the current target.
[out] | scalex | Variable to be filled with the horizontal scaling factor |
[out] | scaley | Variable to be filled with the vertical scaling factor |
Rect SDL2pp::Renderer::GetViewport | ( | ) | const |
Get the drawing area for the current target.
float SDL2pp::Renderer::GetXScale | ( | ) | const |
Get the drawing scale for the current target.
float SDL2pp::Renderer::GetYScale | ( | ) | const |
Get the drawing scale for the current target.
Deleted assignment operator.
This class is not copyable
Move assignment operator.
[in] | other | SDL2pp::Renderer object to move data from |
Renderer & SDL2pp::Renderer::Present | ( | ) |
Update the screen with any rendering performed since the previous call.
SDL's rendering functions operate on a backbuffer; that is, calling a rendering function such as SDL_RenderDrawLine() does not directly put a line on the screen, but rather updates the backbuffer. As such, you compose your entire scene and present the composed backbuffer to the screen as a complete picture.
Therefore, when using SDL's rendering API, one does all drawing intended for the frame, and then calls this function once per frame to present the final drawing to the user.
void SDL2pp::Renderer::ReadPixels | ( | const Optional< Rect > & | rect, |
Uint32 | format, | ||
void * | pixels, | ||
int | pitch | ||
) |
Read pixels from the current rendering target.
[in] | rect | Area to read or NullOpt for the entire render target |
[in] | format | Desired format of the pixel data, or 0 to use the format of the rendering target |
[in] | pixels | Pointer to memory to be filled with pixel data |
[in] | pitch | Number of bytes in a row of pixel data, including padding between lines |
SDL2pp::Exception |
Set the clipping rectangle for rendering.
[in] | rect | New clipping rectangle or NullOpt to disable clipping |
SDL2pp::Exception |
Renderer & SDL2pp::Renderer::SetDrawBlendMode | ( | SDL_BlendMode | blendMode = SDL_BLENDMODE_NONE | ) |
Set the blend mode used for drawing operations.
[in] | blendMode | SDL_BlendMode to use for blending |
SDL2pp::Exception |
Set color user for drawing operations.
[in] | color | Color to draw on the rendering target |
SDL2pp::Exception |
Renderer & SDL2pp::Renderer::SetDrawColor | ( | Uint8 | r = 0 , |
Uint8 | g = 0 , |
||
Uint8 | b = 0 , |
||
Uint8 | a = 255 |
||
) |
Set color user for drawing operations.
[in] | r | Red value used to draw on the rendering target |
[in] | g | Green value used to draw on the rendering target |
[in] | b | Blue value used to draw on the rendering target |
[in] | a | Alpha value used to draw on the rendering target |
SDL2pp::Exception |
Renderer & SDL2pp::Renderer::SetLogicalSize | ( | int | w, |
int | h | ||
) |
Set a device independent resolution for rendering.
[in] | w | Width of the logical resolution |
[in] | h | Height of the logical resolution |
SDL2pp::Exception |
Renderer & SDL2pp::Renderer::SetScale | ( | float | scaleX, |
float | scaleY | ||
) |
Set the drawing scale for rendering on the current target.
[in] | scaleX | Horizontal scaling factor |
[in] | scaleY | Vertical scaling factor |
SDL2pp::Exception |
Renderer & SDL2pp::Renderer::SetTarget | ( | ) |
Set current render target to specified texture.
[in] | texture | Target texture, SDL2pp::Texture created with SDL_TEXTUREACCESS_TARGET |
SDL2pp::Exception |
Set the drawing area for rendering on the current target.
[in] | rect | Rectangle representing the drawing area or NullOpt to set the viewport to the entire target |
SDL2pp::Exception |
bool SDL2pp::Renderer::TargetSupported | ( | ) | const |
Determine whether a window supports the use of render targets.