cpp-sdl2
C++ header-only SDL2 wrapper
sdl::Renderer Class Reference

Class that represent a SDL2 2D renderer. More...

#include <renderer.hpp>

Public Member Functions

 Renderer (SDL_Renderer *renderer)
 Construct a renderer from the SDL_Renderer C object. More...
 
 Renderer ()
 Default ctor, create an empty renderer object. More...
 
 Renderer (Renderer &&other) noexcept
 Default move ctor. More...
 
Rendereroperator= (Renderer &&other) noexcept
 Move a renderer to this one. More...
 
 ~Renderer ()
 Destroy the renderer automaticlally when object goes out of scope. More...
 
 Renderer (Renderer const &)=delete
 This is a managed RAII resource. this object is not copyable. More...
 
Rendereroperator= (Renderer const &)=delete
 This is a managed RAII resource. this object is not copyable. More...
 
SDL_Renderer * ptr () const
 Return a pointer to the wrapped C SDL_Renderer. More...
 
void get_info (SDL_RendererInfo &info) const
 Populate renderinfo structure. More...
 
SDL_RendererInfo info () const
 Get renderer infos. More...
 
Color drawcolor () const
 
void set_drawcolor (Uint8 r, Uint8 g, Uint8 b, Uint8 a=SDL_ALPHA_OPAQUE) const
 Set the drawcolor from color values as bytes. More...
 
void set_drawcolor (Color const &c) const
 Set the drawcolor from color struct. More...
 
Rect cliprect () const
 Get the clipping rectangle. More...
 
void set_cliprect (Rect const &r) const
 Set the clipping rectangle. More...
 
bool clip_enabled () const
 Return true if clipping is enable. More...
 
void disable_clip () const
 Disable the clipping rectangle. More...
 
bool intscale () const
 Get the current integer scale. More...
 
void set_intscale (bool intscale) const
 Set the integer scale. More...
 
Texture make_texture (Uint32 format, SDL_TextureAccess access, int w, int h) const
 Make a new texture. More...
 
Texture make_texture (Uint32 format, SDL_TextureAccess access, Vec2i size) const
 Make a new texture. More...
 
Texture make_texture (Surface const &surface) const
 Make a texture from a surface. More...
 
Texture make_texture (std::string const &filename) const
 Make a texture from a file. More...
 
void render_copy (Texture const &tex, Rect const &source_rect, Rect const &dest_rect) const
 
void present () const
 Present renderer. More...
 
void clear () const
 Clear renderer. More...
 
void clear (Color const &c) const
 Clear with specified color. More...
 
void draw_line (Vec2i const &pos1, Vec2i const &pos2) const
 Draw line between two points. More...
 
void draw_line (Vec2i const &pos1, Vec2i const &pos2, Color const &c) const
 Draw line between two points with specified color. More...
 
void draw_lines (std::vector< Vec2i > const &points) const
 Draw array of lines. More...
 
void draw_lines (std::vector< Vec2i > const &points, Color const &c) const
 Draw array of lines with specified color. More...
 
void draw_point (Vec2i const &point) const
 Draw point. More...
 
void draw_point (Vec2i const &point, Color const &c) const
 Draw point with specified color. More...
 
void draw_points (std::vector< Vec2i > const &points) const
 Draw array of points. More...
 
void draw_points (std::vector< Vec2i > const &points, Color const &c) const
 Draw array of points with specified color. More...
 
void draw_ray (Vec2i const &orig, Vec2i const &ray) const
 
void draw_ray (Vec2i const &orig, Vec2i const &ray, Color const &c) const
 
void draw_rect (Rect const &rect) const
 Draw rectangle. More...
 
void draw_rect (Rect const &rect, Color const &c) const
 Draw rectangle with specified color. More...
 
void draw_rects (std::vector< Rect > const &rects) const
 Draw array of rectangles. More...
 
void draw_rects (std::vector< Rect > const &rects, const Color &c) const
 Draw array of rectangles with specified colors. More...
 
void fill_rect (Rect const &rect) const
 Fill rectangle. More...
 
void fill_rect (Rect const &rect, Color const &c) const
 Fill rectangle with specified color. More...
 
void fill_rects (std::vector< Rect > const &rects) const
 Fill array of rectangles. More...
 
void fill_rects (std::vector< Rect > const &rects, Color const &c)
 Fill array of rectangles with specified colors. More...
 

Private Attributes

SDL_Renderer * renderer_ = nullptr
 Pointer to raw SDL_Renderer. More...
 

Detailed Description

Class that represent a SDL2 2D renderer.

Definition at line 18 of file renderer.hpp.

Constructor & Destructor Documentation

◆ Renderer() [1/4]

sdl::Renderer::Renderer ( SDL_Renderer *  renderer)
inlineexplicit

Construct a renderer from the SDL_Renderer C object.

Definition at line 22 of file renderer.hpp.

◆ Renderer() [2/4]

sdl::Renderer::Renderer ( )
inline

Default ctor, create an empty renderer object.

Definition at line 25 of file renderer.hpp.

Referenced by ~Renderer().

◆ Renderer() [3/4]

sdl::Renderer::Renderer ( Renderer &&  other)
inlinenoexcept

Default move ctor.

Definition at line 28 of file renderer.hpp.

◆ ~Renderer()

sdl::Renderer::~Renderer ( )
inline

Destroy the renderer automaticlally when object goes out of scope.

Definition at line 43 of file renderer.hpp.

References operator=(), Renderer(), and renderer_.

◆ Renderer() [4/4]

sdl::Renderer::Renderer ( Renderer const &  )
delete

This is a managed RAII resource. this object is not copyable.

Member Function Documentation

◆ clear() [1/2]

void sdl::Renderer::clear ( ) const
inline

Clear renderer.

Definition at line 152 of file renderer.hpp.

References renderer_.

Referenced by clear().

◆ clear() [2/2]

void sdl::Renderer::clear ( Color const &  c) const
inline

Clear with specified color.

Definition at line 158 of file renderer.hpp.

References clear(), and set_drawcolor().

◆ clip_enabled()

bool sdl::Renderer::clip_enabled ( ) const
inline

Return true if clipping is enable.

Definition at line 102 of file renderer.hpp.

References renderer_.

◆ cliprect()

Rect sdl::Renderer::cliprect ( ) const
inline

Get the clipping rectangle.

Definition at line 88 of file renderer.hpp.

References renderer_.

◆ disable_clip()

void sdl::Renderer::disable_clip ( ) const
inline

Disable the clipping rectangle.

Definition at line 105 of file renderer.hpp.

References renderer_.

◆ draw_line() [1/2]

void sdl::Renderer::draw_line ( Vec2i const &  pos1,
Vec2i const &  pos2 
) const
inline

Draw line between two points.

Definition at line 165 of file renderer.hpp.

References renderer_.

Referenced by draw_line(), and draw_ray().

◆ draw_line() [2/2]

void sdl::Renderer::draw_line ( Vec2i const &  pos1,
Vec2i const &  pos2,
Color const &  c 
) const
inline

Draw line between two points with specified color.

Definition at line 172 of file renderer.hpp.

References draw_line(), and set_drawcolor().

◆ draw_lines() [1/2]

void sdl::Renderer::draw_lines ( std::vector< Vec2i > const &  points) const
inline

Draw array of lines.

Definition at line 179 of file renderer.hpp.

References renderer_.

Referenced by draw_lines().

◆ draw_lines() [2/2]

void sdl::Renderer::draw_lines ( std::vector< Vec2i > const &  points,
Color const &  c 
) const
inline

Draw array of lines with specified color.

Definition at line 186 of file renderer.hpp.

References draw_lines(), and set_drawcolor().

◆ draw_point() [1/2]

void sdl::Renderer::draw_point ( Vec2i const &  point) const
inline

Draw point.

Definition at line 193 of file renderer.hpp.

References renderer_.

Referenced by draw_point().

◆ draw_point() [2/2]

void sdl::Renderer::draw_point ( Vec2i const &  point,
Color const &  c 
) const
inline

Draw point with specified color.

Definition at line 200 of file renderer.hpp.

References draw_point(), and set_drawcolor().

◆ draw_points() [1/2]

void sdl::Renderer::draw_points ( std::vector< Vec2i > const &  points) const
inline

Draw array of points.

Definition at line 207 of file renderer.hpp.

References renderer_.

Referenced by draw_points().

◆ draw_points() [2/2]

void sdl::Renderer::draw_points ( std::vector< Vec2i > const &  points,
Color const &  c 
) const
inline

Draw array of points with specified color.

Definition at line 214 of file renderer.hpp.

References draw_points(), and set_drawcolor().

◆ draw_ray() [1/2]

void sdl::Renderer::draw_ray ( Vec2i const &  orig,
Vec2i const &  ray 
) const
inline

Definition at line 220 of file renderer.hpp.

References draw_line().

◆ draw_ray() [2/2]

void sdl::Renderer::draw_ray ( Vec2i const &  orig,
Vec2i const &  ray,
Color const &  c 
) const
inline

Definition at line 221 of file renderer.hpp.

References draw_line().

◆ draw_rect() [1/2]

void sdl::Renderer::draw_rect ( Rect const &  rect) const
inline

Draw rectangle.

Definition at line 227 of file renderer.hpp.

References renderer_.

Referenced by draw_rect().

◆ draw_rect() [2/2]

void sdl::Renderer::draw_rect ( Rect const &  rect,
Color const &  c 
) const
inline

Draw rectangle with specified color.

Definition at line 233 of file renderer.hpp.

References draw_rect(), and set_drawcolor().

◆ draw_rects() [1/2]

void sdl::Renderer::draw_rects ( std::vector< Rect > const &  rects) const
inline

Draw array of rectangles.

Definition at line 240 of file renderer.hpp.

References renderer_.

Referenced by draw_rects().

◆ draw_rects() [2/2]

void sdl::Renderer::draw_rects ( std::vector< Rect > const &  rects,
const Color c 
) const
inline

Draw array of rectangles with specified colors.

Definition at line 246 of file renderer.hpp.

References draw_rects(), and set_drawcolor().

◆ drawcolor()

Color sdl::Renderer::drawcolor ( ) const
inline

Definition at line 69 of file renderer.hpp.

References renderer_.

◆ fill_rect() [1/2]

void sdl::Renderer::fill_rect ( Rect const &  rect) const
inline

Fill rectangle.

Definition at line 253 of file renderer.hpp.

References renderer_.

Referenced by fill_rect().

◆ fill_rect() [2/2]

void sdl::Renderer::fill_rect ( Rect const &  rect,
Color const &  c 
) const
inline

Fill rectangle with specified color.

Definition at line 258 of file renderer.hpp.

References fill_rect(), and set_drawcolor().

◆ fill_rects() [1/2]

void sdl::Renderer::fill_rects ( std::vector< Rect > const &  rects) const
inline

Fill array of rectangles.

Definition at line 265 of file renderer.hpp.

References renderer_.

Referenced by fill_rects().

◆ fill_rects() [2/2]

void sdl::Renderer::fill_rects ( std::vector< Rect > const &  rects,
Color const &  c 
)
inline

Fill array of rectangles with specified colors.

Definition at line 271 of file renderer.hpp.

References fill_rects(), and set_drawcolor().

◆ get_info()

void sdl::Renderer::get_info ( SDL_RendererInfo &  info) const
inline

Populate renderinfo structure.

Definition at line 55 of file renderer.hpp.

References renderer_.

Referenced by info().

◆ info()

SDL_RendererInfo sdl::Renderer::info ( ) const
inline

Get renderer infos.

Definition at line 61 of file renderer.hpp.

References get_info().

◆ intscale()

bool sdl::Renderer::intscale ( ) const
inline

Get the current integer scale.

Definition at line 112 of file renderer.hpp.

References renderer_.

◆ make_texture() [1/4]

Texture sdl::Renderer::make_texture ( Uint32  format,
SDL_TextureAccess  access,
int  w,
int  h 
) const
inline

Make a new texture.

Definition at line 122 of file renderer.hpp.

References renderer_.

◆ make_texture() [2/4]

Texture sdl::Renderer::make_texture ( Uint32  format,
SDL_TextureAccess  access,
Vec2i  size 
) const
inline

Make a new texture.

Definition at line 128 of file renderer.hpp.

References renderer_.

◆ make_texture() [3/4]

Texture sdl::Renderer::make_texture ( Surface const &  surface) const
inline

Make a texture from a surface.

Definition at line 134 of file renderer.hpp.

References renderer_.

◆ make_texture() [4/4]

Texture sdl::Renderer::make_texture ( std::string const &  filename) const
inline

Make a texture from a file.

Parameters
filenamefile path

Definition at line 138 of file renderer.hpp.

References renderer_.

◆ operator=() [1/2]

Renderer& sdl::Renderer::operator= ( Renderer &&  other)
inlinenoexcept

Move a renderer to this one.

Definition at line 31 of file renderer.hpp.

References renderer_.

Referenced by ~Renderer().

◆ operator=() [2/2]

Renderer& sdl::Renderer::operator= ( Renderer const &  )
delete

This is a managed RAII resource. this object is not copyable.

◆ present()

void sdl::Renderer::present ( ) const
inline

Present renderer.

Definition at line 149 of file renderer.hpp.

References renderer_.

◆ ptr()

SDL_Renderer* sdl::Renderer::ptr ( ) const
inline

Return a pointer to the wrapped C SDL_Renderer.

Definition at line 52 of file renderer.hpp.

References renderer_.

Referenced by render_copy().

◆ render_copy()

void sdl::Renderer::render_copy ( Texture const &  tex,
Rect const &  source_rect,
Rect const &  dest_rect 
) const
inline

Definition at line 140 of file renderer.hpp.

References ptr(), and renderer_.

◆ set_cliprect()

void sdl::Renderer::set_cliprect ( Rect const &  r) const
inline

Set the clipping rectangle.

Definition at line 96 of file renderer.hpp.

References renderer_.

◆ set_drawcolor() [1/2]

void sdl::Renderer::set_drawcolor ( Uint8  r,
Uint8  g,
Uint8  b,
Uint8  a = SDL_ALPHA_OPAQUE 
) const
inline

Set the drawcolor from color values as bytes.

Definition at line 78 of file renderer.hpp.

References sdl::simd::a, and renderer_.

Referenced by clear(), draw_line(), draw_lines(), draw_point(), draw_points(), draw_rect(), draw_rects(), fill_rect(), and fill_rects().

◆ set_drawcolor() [2/2]

void sdl::Renderer::set_drawcolor ( Color const &  c) const
inline

Set the drawcolor from color struct.

Definition at line 85 of file renderer.hpp.

References set_drawcolor().

Referenced by set_drawcolor().

◆ set_intscale()

void sdl::Renderer::set_intscale ( bool  intscale) const
inline

Set the integer scale.

Definition at line 115 of file renderer.hpp.

References renderer_.

Member Data Documentation

◆ renderer_


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