10 #include <SDL_render.h> 37 other.renderer_ =
nullptr;
57 if (SDL_GetRendererInfo(
renderer_, &info) != 0)
throw Exception{
"SDL_GetRendererInfo"};
61 SDL_RendererInfo
info()
const 63 SDL_RendererInfo
info;
72 if (SDL_GetRenderDrawColor(
renderer_, &c.r, &c.g, &c.b, &c.a) != 0)
73 throw Exception{
"SDL_GetRenderDrawColor"};
78 void set_drawcolor(Uint8 r, Uint8 g, Uint8 b, Uint8
a = SDL_ALPHA_OPAQUE)
const 80 if (SDL_SetRenderDrawColor(
renderer_, r, g, b,
a) != 0)
81 throw Exception{
"SDL_SetRenderDrawColor"};
98 if (SDL_RenderSetClipRect(
renderer_, &r) != 0)
throw Exception{
"SDL_RenderSetClipRect"};
107 if (SDL_RenderSetClipRect(
renderer_,
nullptr) != 0)
108 throw Exception{
"SDL_RenderSetClipRect"};
117 if (SDL_RenderSetIntegerScale(
renderer_, SDL_bool(intscale)) != 0)
118 throw Exception{
"SDL_RenderSetIntegerScale"};
145 SDL_RenderCopy(
renderer_, const_cast<Texture&>(tex).
ptr(), &source_rect, &dest_rect);
167 if (SDL_RenderDrawLine(
renderer_, pos1.x, pos1.y, pos2.x, pos2.y) != 0)
181 if (SDL_RenderDrawLines(
renderer_, &points[0], (
int)points.size()) != 0)
195 if (SDL_RenderDrawPoint(
renderer_, point.x, point.y) != 0)
209 if (SDL_RenderDrawPoints(
renderer_, &points[0], (
int)points.size()) != 0)
242 if (SDL_RenderDrawRects(
renderer_, &rects[0], (
int)rects.size()) != 0)
267 if (SDL_RenderFillRects(
renderer_, &rects[0], (
int)rects.size()) != 0)
void draw_points(std::vector< Vec2i > const &points, Color const &c) const
Draw array of points with specified color.
void set_drawcolor(Uint8 r, Uint8 g, Uint8 b, Uint8 a=SDL_ALPHA_OPAQUE) const
Set the drawcolor from color values as bytes.
Texture make_texture(Uint32 format, SDL_TextureAccess access, Vec2i size) const
Make a new texture.
sdl::Rect, C++ wrapping of SDL_Rect
void draw_line(Vec2i const &pos1, Vec2i const &pos2) const
Draw line between two points.
void fill_rect(Rect const &rect) const
Fill rectangle.
void get_info(SDL_RendererInfo &info) const
Populate renderinfo structure.
Generic templated 2D vector class.
void set_drawcolor(Color const &c) const
Set the drawcolor from color struct.
void draw_line(Vec2i const &pos1, Vec2i const &pos2, Color const &c) const
Draw line between two points with specified color.
Rect cliprect() const
Get the clipping rectangle.
void draw_ray(Vec2i const &orig, Vec2i const &ray, Color const &c) const
Texture make_texture(std::string const &filename) const
Make a texture from a file.
void draw_point(Vec2i const &point) const
Draw point.
Renderer(Renderer &&other) noexcept
Default move ctor.
void draw_lines(std::vector< Vec2i > const &points, Color const &c) const
Draw array of lines with specified color.
bool clip_enabled() const
Return true if clipping is enable.
void draw_ray(Vec2i const &orig, Vec2i const &ray) const
void present() const
Present renderer.
Class that represet a renderer texture.
void draw_rect(Rect const &rect, Color const &c) const
Draw rectangle with specified color.
void fill_rect(Rect const &rect, Color const &c) const
Fill rectangle with specified color.
C++ wrapping around the SDL_Color structure.
Define to deactivate exception support.
bool intscale() const
Get the current integer scale.
void fill_rects(std::vector< Rect > const &rects) const
Fill array of rectangles.
void draw_rects(std::vector< Rect > const &rects, const Color &c) const
Draw array of rectangles with specified colors.
Texture make_texture(Uint32 format, SDL_TextureAccess access, int w, int h) const
Make a new texture.
Renderer()
Default ctor, create an empty renderer object.
void draw_point(Vec2i const &point, Color const &c) const
Draw point with specified color.
SDL_RendererInfo info() const
Get renderer infos.
Texture make_texture(Surface const &surface) const
Make a texture from a surface.
SDL_Renderer * renderer_
Pointer to raw SDL_Renderer.
SDL_Renderer * ptr() const
Return a pointer to the wrapped C SDL_Renderer.
void draw_rects(std::vector< Rect > const &rects) const
Draw array of rectangles.
void draw_lines(std::vector< Vec2i > const &points) const
Draw array of lines.
void draw_rect(Rect const &rect) const
Draw rectangle.
void draw_points(std::vector< Vec2i > const &points) const
Draw array of points.
Represent an SDL_Surface.
Renderer(SDL_Renderer *renderer)
Construct a renderer from the SDL_Renderer C object.
void set_cliprect(Rect const &r) const
Set the clipping rectangle.
void render_copy(Texture const &tex, Rect const &source_rect, Rect const &dest_rect) const
~Renderer()
Destroy the renderer automaticlally when object goes out of scope.
void clear(Color const &c) const
Clear with specified color.
void fill_rects(std::vector< Rect > const &rects, Color const &c)
Fill array of rectangles with specified colors.
void disable_clip() const
Disable the clipping rectangle.
void set_intscale(bool intscale) const
Set the integer scale.
Define to deactivate exception support.
Renderer & operator=(Renderer &&other) noexcept
Move a renderer to this one.
void clear() const
Clear renderer.
Class that represent a SDL2 2D renderer.