Make setters return reference to self: Renderer

This commit is contained in:
Dmitry Marakasov 2015-01-18 03:52:19 +03:00
parent 7e1625a488
commit f9ef31c4b2
2 changed files with 134 additions and 52 deletions

View File

@ -61,13 +61,15 @@ SDL_Renderer* Renderer::Get() const {
return renderer_; return renderer_;
} }
void Renderer::Present() { Renderer& Renderer::Present() {
SDL_RenderPresent(renderer_); SDL_RenderPresent(renderer_);
return *this;
} }
void Renderer::Clear() { Renderer& Renderer::Clear() {
if (SDL_RenderClear(renderer_) != 0) if (SDL_RenderClear(renderer_) != 0)
throw Exception("SDL_RenderClear failed"); throw Exception("SDL_RenderClear failed");
return *this;
} }
void Renderer::GetInfo(SDL_RendererInfo* info) { void Renderer::GetInfo(SDL_RendererInfo* info) {
@ -80,46 +82,54 @@ void Renderer::GetInfo(SDL_RendererInfo& info) {
throw Exception("SDL_GetRendererInfo failed"); throw Exception("SDL_GetRendererInfo failed");
} }
void Renderer::Copy(Texture& texture, const Optional<Rect>& srcrect, const Optional<Rect>& dstrect) { Renderer& Renderer::Copy(Texture& texture, const Optional<Rect>& srcrect, const Optional<Rect>& dstrect) {
if (SDL_RenderCopy(renderer_, texture.Get(), srcrect ? &*srcrect : nullptr, dstrect ? &*dstrect : nullptr) != 0) if (SDL_RenderCopy(renderer_, texture.Get(), srcrect ? &*srcrect : nullptr, dstrect ? &*dstrect : nullptr) != 0)
throw Exception("SDL_RenderCopy failed"); throw Exception("SDL_RenderCopy failed");
return *this;
} }
void Renderer::Copy(Texture& texture, const Optional<Rect>& srcrect, const Optional<Rect>& dstrect, double angle, const Optional<Point>& center, int flip) { Renderer& Renderer::Copy(Texture& texture, const Optional<Rect>& srcrect, const Optional<Rect>& dstrect, double angle, const Optional<Point>& center, int flip) {
if (SDL_RenderCopyEx(renderer_, texture.Get(), srcrect ? &*srcrect : nullptr, dstrect ? &*dstrect : nullptr, angle, center ? &*center : nullptr, static_cast<SDL_RendererFlip>(flip)) != 0) if (SDL_RenderCopyEx(renderer_, texture.Get(), srcrect ? &*srcrect : nullptr, dstrect ? &*dstrect : nullptr, angle, center ? &*center : nullptr, static_cast<SDL_RendererFlip>(flip)) != 0)
throw Exception("SDL_RenderCopyEx failed"); throw Exception("SDL_RenderCopyEx failed");
return *this;
} }
void Renderer::SetDrawColor(Uint8 r, Uint8 g, Uint8 b, Uint8 a) { Renderer& Renderer::SetDrawColor(Uint8 r, Uint8 g, Uint8 b, Uint8 a) {
if (SDL_SetRenderDrawColor(renderer_, r, g, b, a) != 0) if (SDL_SetRenderDrawColor(renderer_, r, g, b, a) != 0)
throw Exception("SDL_SetRenderDrawColor failed"); throw Exception("SDL_SetRenderDrawColor failed");
return *this;
} }
void Renderer::SetTarget() { Renderer& Renderer::SetTarget() {
if (SDL_SetRenderTarget(renderer_, nullptr) != 0) if (SDL_SetRenderTarget(renderer_, nullptr) != 0)
throw Exception("SDL_SetRenderTarget failed"); throw Exception("SDL_SetRenderTarget failed");
return *this;
} }
void Renderer::SetTarget(Texture& texture) { Renderer& Renderer::SetTarget(Texture& texture) {
if (SDL_SetRenderTarget(renderer_, texture.Get()) != 0) if (SDL_SetRenderTarget(renderer_, texture.Get()) != 0)
throw Exception("SDL_SetRenderTarget failed"); throw Exception("SDL_SetRenderTarget failed");
return *this;
} }
void Renderer::SetDrawBlendMode(SDL_BlendMode blendMode) { Renderer& Renderer::SetDrawBlendMode(SDL_BlendMode blendMode) {
if (SDL_SetRenderDrawBlendMode(renderer_, blendMode) != 0) if (SDL_SetRenderDrawBlendMode(renderer_, blendMode) != 0)
throw Exception("SDL_SetRenderDrawBlendMode failed"); throw Exception("SDL_SetRenderDrawBlendMode failed");
return *this;
} }
void Renderer::DrawPoint(int x, int y) { Renderer& Renderer::DrawPoint(int x, int y) {
if (SDL_RenderDrawPoint(renderer_, x, y) != 0) if (SDL_RenderDrawPoint(renderer_, x, y) != 0)
throw Exception("SDL_RenderDrawPoint failed"); throw Exception("SDL_RenderDrawPoint failed");
return *this;
} }
void Renderer::DrawPoint(const Point& p) { Renderer& Renderer::DrawPoint(const Point& p) {
DrawPoint(p.x, p.y); DrawPoint(p.x, p.y);
return *this;
} }
void Renderer::DrawPoints(const Point* points, int count) { Renderer& Renderer::DrawPoints(const Point* points, int count) {
std::vector<SDL_Point> sdl_points; std::vector<SDL_Point> sdl_points;
sdl_points.reserve(count); sdl_points.reserve(count);
for (const Point* p = points; p != points + count; ++p) for (const Point* p = points; p != points + count; ++p)
@ -127,18 +137,22 @@ void Renderer::DrawPoints(const Point* points, int count) {
if (SDL_RenderDrawPoints(renderer_, sdl_points.data(), sdl_points.size()) != 0) if (SDL_RenderDrawPoints(renderer_, sdl_points.data(), sdl_points.size()) != 0)
throw Exception("SDL_RenderDrawPoints failed"); throw Exception("SDL_RenderDrawPoints failed");
return *this;
} }
void Renderer::DrawLine(int x1, int y1, int x2, int y2) { Renderer& Renderer::DrawLine(int x1, int y1, int x2, int y2) {
if (SDL_RenderDrawLine(renderer_, x1, y1, x2, y2) != 0) if (SDL_RenderDrawLine(renderer_, x1, y1, x2, y2) != 0)
throw Exception("SDL_RenderDrawLine failed"); throw Exception("SDL_RenderDrawLine failed");
return *this;
} }
void Renderer::DrawLine(const Point& p1, const Point& p2) { Renderer& Renderer::DrawLine(const Point& p1, const Point& p2) {
DrawLine(p1.x, p1.y, p2.x, p2.y); DrawLine(p1.x, p1.y, p2.x, p2.y);
return *this;
} }
void Renderer::DrawLines(const Point* points, int count) { Renderer& Renderer::DrawLines(const Point* points, int count) {
std::vector<SDL_Point> sdl_points; std::vector<SDL_Point> sdl_points;
sdl_points.reserve(count); sdl_points.reserve(count);
for (const Point* p = points; p != points + count; ++p) for (const Point* p = points; p != points + count; ++p)
@ -146,24 +160,29 @@ void Renderer::DrawLines(const Point* points, int count) {
if (SDL_RenderDrawLines(renderer_, sdl_points.data(), sdl_points.size()) != 0) if (SDL_RenderDrawLines(renderer_, sdl_points.data(), sdl_points.size()) != 0)
throw Exception("SDL_RenderDrawLines failed"); throw Exception("SDL_RenderDrawLines failed");
return *this;
} }
void Renderer::DrawRect(int x1, int y1, int x2, int y2) { Renderer& Renderer::DrawRect(int x1, int y1, int x2, int y2) {
SDL_Rect rect = {x1, y1, x2 - x1 + 1, y2 - y1 + 1}; SDL_Rect rect = {x1, y1, x2 - x1 + 1, y2 - y1 + 1};
if (SDL_RenderDrawRect(renderer_, &rect) != 0) if (SDL_RenderDrawRect(renderer_, &rect) != 0)
throw Exception("SDL_RenderDrawRect failed"); throw Exception("SDL_RenderDrawRect failed");
return *this;
} }
void Renderer::DrawRect(const Point& p1, const Point& p2) { Renderer& Renderer::DrawRect(const Point& p1, const Point& p2) {
DrawRect(p1.x, p1.y, p2.x, p2.y); DrawRect(p1.x, p1.y, p2.x, p2.y);
return *this;
} }
void Renderer::DrawRect(const Rect& r) { Renderer& Renderer::DrawRect(const Rect& r) {
if (SDL_RenderDrawRect(renderer_, &r) != 0) if (SDL_RenderDrawRect(renderer_, &r) != 0)
throw Exception("SDL_RenderDrawRect failed"); throw Exception("SDL_RenderDrawRect failed");
return *this;
} }
void Renderer::DrawRects(const Rect* rects, int count) { Renderer& Renderer::DrawRects(const Rect* rects, int count) {
std::vector<SDL_Rect> sdl_rects; std::vector<SDL_Rect> sdl_rects;
sdl_rects.reserve(count); sdl_rects.reserve(count);
for (const Rect* r = rects; r != rects + count; ++r) for (const Rect* r = rects; r != rects + count; ++r)
@ -171,24 +190,29 @@ void Renderer::DrawRects(const Rect* rects, int count) {
if (SDL_RenderDrawRects(renderer_, sdl_rects.data(), sdl_rects.size()) != 0) if (SDL_RenderDrawRects(renderer_, sdl_rects.data(), sdl_rects.size()) != 0)
throw Exception("SDL_RenderDrawRects failed"); throw Exception("SDL_RenderDrawRects failed");
return *this;
} }
void Renderer::FillRect(int x1, int y1, int x2, int y2) { Renderer& Renderer::FillRect(int x1, int y1, int x2, int y2) {
SDL_Rect rect = {x1, y1, x2 - x1 + 1, y2 - y1 + 1}; SDL_Rect rect = {x1, y1, x2 - x1 + 1, y2 - y1 + 1};
if (SDL_RenderFillRect(renderer_, &rect) != 0) if (SDL_RenderFillRect(renderer_, &rect) != 0)
throw Exception("SDL_RenderFillRect failed"); throw Exception("SDL_RenderFillRect failed");
return *this;
} }
void Renderer::FillRect(const Point& p1, const Point& p2) { Renderer& Renderer::FillRect(const Point& p1, const Point& p2) {
FillRect(p1.x, p1.y, p2.x, p2.y); FillRect(p1.x, p1.y, p2.x, p2.y);
return *this;
} }
void Renderer::FillRect(const Rect& r) { Renderer& Renderer::FillRect(const Rect& r) {
if (SDL_RenderFillRect(renderer_, &r) != 0) if (SDL_RenderFillRect(renderer_, &r) != 0)
throw Exception("SDL_RenderFillRect failed"); throw Exception("SDL_RenderFillRect failed");
return *this;
} }
void Renderer::FillRects(const Rect* rects, int count) { Renderer& Renderer::FillRects(const Rect* rects, int count) {
std::vector<SDL_Rect> sdl_rects; std::vector<SDL_Rect> sdl_rects;
sdl_rects.reserve(count); sdl_rects.reserve(count);
for (const Rect* r = rects; r != rects + count; ++r) for (const Rect* r = rects; r != rects + count; ++r)
@ -196,6 +220,8 @@ void Renderer::FillRects(const Rect* rects, int count) {
if (SDL_RenderFillRects(renderer_, sdl_rects.data(), sdl_rects.size()) != 0) if (SDL_RenderFillRects(renderer_, sdl_rects.data(), sdl_rects.size()) != 0)
throw Exception("SDL_RenderFillRects failed"); throw Exception("SDL_RenderFillRects failed");
return *this;
} }
void Renderer::ReadPixels(const Optional<Rect>& rect, Uint32 format, void* pixels, int pitch) { void Renderer::ReadPixels(const Optional<Rect>& rect, Uint32 format, void* pixels, int pitch) {
@ -203,24 +229,28 @@ void Renderer::ReadPixels(const Optional<Rect>& rect, Uint32 format, void* pixel
throw Exception("SDL_RenderReadPixels failed"); throw Exception("SDL_RenderReadPixels failed");
} }
void Renderer::SetClipRect(const Optional<Rect>& rect) { Renderer& Renderer::SetClipRect(const Optional<Rect>& rect) {
if (SDL_RenderSetClipRect(renderer_, rect ? &*rect : nullptr) != 0) if (SDL_RenderSetClipRect(renderer_, rect ? &*rect : nullptr) != 0)
throw Exception("SDL_RenderSetClipRect failed"); throw Exception("SDL_RenderSetClipRect failed");
return *this;
} }
void Renderer::SetLogicalSize(int w, int h) { Renderer& Renderer::SetLogicalSize(int w, int h) {
if (SDL_RenderSetLogicalSize(renderer_, w, h) != 0) if (SDL_RenderSetLogicalSize(renderer_, w, h) != 0)
throw Exception("SDL_RenderSetLogicalSize failed"); throw Exception("SDL_RenderSetLogicalSize failed");
return *this;
} }
void Renderer::SetScale(float scaleX, float scaleY) { Renderer& Renderer::SetScale(float scaleX, float scaleY) {
if (SDL_RenderSetScale(renderer_, scaleX, scaleY) != 0) if (SDL_RenderSetScale(renderer_, scaleX, scaleY) != 0)
throw Exception("SDL_RenderSetScale failed"); throw Exception("SDL_RenderSetScale failed");
return *this;
} }
void Renderer::SetViewport(const Optional<Rect>& rect) { Renderer& Renderer::SetViewport(const Optional<Rect>& rect) {
if (SDL_RenderSetViewport(renderer_, rect ? &*rect : nullptr) != 0) if (SDL_RenderSetViewport(renderer_, rect ? &*rect : nullptr) != 0)
throw Exception("SDL_RenderSetViewport failed"); throw Exception("SDL_RenderSetViewport failed");
return *this;
} }
bool Renderer::TargetSupported() const { bool Renderer::TargetSupported() const {

View File

@ -141,20 +141,24 @@ public:
/// drawing intended for the frame, and then calls this function /// drawing intended for the frame, and then calls this function
/// once per frame to present the final drawing to the user. /// once per frame to present the final drawing to the user.
/// ///
/// \returns Reference to self
///
/// \see http://wiki.libsdl.org/SDL_RenderPresent /// \see http://wiki.libsdl.org/SDL_RenderPresent
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void Present(); Renderer& Present();
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Clear the current rendering target with the drawing color /// \brief Clear the current rendering target with the drawing color
/// ///
/// \returns Reference to self
///
/// \throws SDL2pp::Exception /// \throws SDL2pp::Exception
/// ///
/// \see http://wiki.libsdl.org/SDL_RenderClear /// \see http://wiki.libsdl.org/SDL_RenderClear
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void Clear(); Renderer& Clear();
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Get information about a rendering context /// \brief Get information about a rendering context
@ -191,12 +195,14 @@ public:
/// \param[in] dstrect Destination rectangle, NullOpt for the entire /// \param[in] dstrect Destination rectangle, NullOpt for the entire
/// rendering target /// rendering target
/// ///
/// \returns Reference to self
///
/// \throws SDL2pp::Exception /// \throws SDL2pp::Exception
/// ///
/// \see http://wiki.libsdl.org/SDL_RenderCopy /// \see http://wiki.libsdl.org/SDL_RenderCopy
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void Copy(Texture& texture, const Optional<Rect>& srcrect = NullOpt, const Optional<Rect>& dstrect = NullOpt); Renderer& Copy(Texture& texture, const Optional<Rect>& srcrect = NullOpt, const Optional<Rect>& dstrect = NullOpt);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Copy a portion of the texture to the current rendering /// \brief Copy a portion of the texture to the current rendering
@ -214,13 +220,15 @@ public:
/// \param[in] flip SDL_RendererFlip value stating which flipping /// \param[in] flip SDL_RendererFlip value stating which flipping
/// actions should be performed on the texture /// actions should be performed on the texture
/// ///
/// \returns Reference to self
///
/// \throws SDL2pp::Exception /// \throws SDL2pp::Exception
/// ///
/// \see http://wiki.libsdl.org/SDL_RendererFlip /// \see http://wiki.libsdl.org/SDL_RendererFlip
/// \see http://wiki.libsdl.org/SDL_RenderCopyEx /// \see http://wiki.libsdl.org/SDL_RenderCopyEx
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void Copy(Texture& texture, const Optional<Rect>& srcrect, const Optional<Rect>& dstrect, double angle, const Optional<Point>& center = NullOpt, int flip = 0); Renderer& Copy(Texture& texture, const Optional<Rect>& srcrect, const Optional<Rect>& dstrect, double angle, const Optional<Point>& center = NullOpt, int flip = 0);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Set color user for drawing operations /// \brief Set color user for drawing operations
@ -230,22 +238,26 @@ public:
/// \param[in] b Blue value used to draw on the rendering target /// \param[in] b Blue value used to draw on the rendering target
/// \param[in] a Alpha value used to draw on the rendering target /// \param[in] a Alpha value used to draw on the rendering target
/// ///
/// \returns Reference to self
///
/// \throws SDL2pp::Exception /// \throws SDL2pp::Exception
/// ///
/// \see http://wiki.libsdl.org/SDL_SetRenderDrawColor /// \see http://wiki.libsdl.org/SDL_SetRenderDrawColor
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void SetDrawColor(Uint8 r, Uint8 g, Uint8 b, Uint8 a = 255); Renderer& SetDrawColor(Uint8 r, Uint8 g, Uint8 b, Uint8 a = 255);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Set current render target to default /// \brief Set current render target to default
/// ///
/// \returns Reference to self
///
/// \throws SDL2pp::Exception /// \throws SDL2pp::Exception
/// ///
/// \see http://wiki.libsdl.org/SDL_SetRenderTarget /// \see http://wiki.libsdl.org/SDL_SetRenderTarget
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void SetTarget(); Renderer& SetTarget();
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Set current render target to specified texture /// \brief Set current render target to specified texture
@ -253,25 +265,29 @@ public:
/// \param[in] texture Target texture, SDL2pp::Texture created with /// \param[in] texture Target texture, SDL2pp::Texture created with
/// SDL_TEXTUREACCESS_TARGET /// SDL_TEXTUREACCESS_TARGET
/// ///
/// \returns Reference to self
///
/// \throws SDL2pp::Exception /// \throws SDL2pp::Exception
/// ///
/// \see http://wiki.libsdl.org/SDL_SetRenderTarget /// \see http://wiki.libsdl.org/SDL_SetRenderTarget
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void SetTarget(Texture& texture); Renderer& SetTarget(Texture& texture);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Set the blend mode used for drawing operations /// \brief Set the blend mode used for drawing operations
/// ///
/// \param[in] blendMode SDL_BlendMode to use for blending /// \param[in] blendMode SDL_BlendMode to use for blending
/// ///
/// \returns Reference to self
///
/// \throws SDL2pp::Exception /// \throws SDL2pp::Exception
/// ///
/// \see http://wiki.libsdl.org/SDL_BlendMode /// \see http://wiki.libsdl.org/SDL_BlendMode
/// \see http://wiki.libsdl.org/SDL_SetRenderDrawBlendMode /// \see http://wiki.libsdl.org/SDL_SetRenderDrawBlendMode
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void SetDrawBlendMode(SDL_BlendMode blendMode); Renderer& SetDrawBlendMode(SDL_BlendMode blendMode);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Draw a point on the current rendering target /// \brief Draw a point on the current rendering target
@ -279,24 +295,28 @@ public:
/// \param[in] x X coordinate of the point /// \param[in] x X coordinate of the point
/// \param[in] y Y coordinate of the point /// \param[in] y Y coordinate of the point
/// ///
/// \returns Reference to self
///
/// \throws SDL2pp::Exception /// \throws SDL2pp::Exception
/// ///
/// \see http://wiki.libsdl.org/SDL_RenderDrawPoint /// \see http://wiki.libsdl.org/SDL_RenderDrawPoint
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void DrawPoint(int x, int y); Renderer& DrawPoint(int x, int y);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Draw a point on the current rendering target /// \brief Draw a point on the current rendering target
/// ///
/// \param[in] p Coordinates of the point /// \param[in] p Coordinates of the point
/// ///
/// \returns Reference to self
///
/// \throws SDL2pp::Exception /// \throws SDL2pp::Exception
/// ///
/// \see http://wiki.libsdl.org/SDL_RenderDrawPoint /// \see http://wiki.libsdl.org/SDL_RenderDrawPoint
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void DrawPoint(const Point& p); Renderer& DrawPoint(const Point& p);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Draw multiple points on the current rendering target /// \brief Draw multiple points on the current rendering target
@ -304,12 +324,14 @@ public:
/// \param[in] points Array of coordinates of points to draw /// \param[in] points Array of coordinates of points to draw
/// \param[in] count Number of points to draw /// \param[in] count Number of points to draw
/// ///
/// \returns Reference to self
///
/// \throws SDL2pp::Exception /// \throws SDL2pp::Exception
/// ///
/// \see http://wiki.libsdl.org/SDL_RenderDrawPoints /// \see http://wiki.libsdl.org/SDL_RenderDrawPoints
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void DrawPoints(const Point* points, int count); Renderer& DrawPoints(const Point* points, int count);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Draw a line on the current rendering target /// \brief Draw a line on the current rendering target
@ -319,12 +341,14 @@ public:
/// \param[in] x2 X coordinate of the end point /// \param[in] x2 X coordinate of the end point
/// \param[in] y2 Y coordinate of the end point /// \param[in] y2 Y coordinate of the end point
/// ///
/// \returns Reference to self
///
/// \throws SDL2pp::Exception /// \throws SDL2pp::Exception
/// ///
/// \see http://wiki.libsdl.org/SDL_RenderDrawLine /// \see http://wiki.libsdl.org/SDL_RenderDrawLine
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void DrawLine(int x1, int y1, int x2, int y2); Renderer& DrawLine(int x1, int y1, int x2, int y2);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Draw a line on the current rendering target /// \brief Draw a line on the current rendering target
@ -332,12 +356,14 @@ public:
/// \param[in] p1 Coordinates of the start point /// \param[in] p1 Coordinates of the start point
/// \param[in] p2 Coordinates of the end point /// \param[in] p2 Coordinates of the end point
/// ///
/// \returns Reference to self
///
/// \throws SDL2pp::Exception /// \throws SDL2pp::Exception
/// ///
/// \see http://wiki.libsdl.org/SDL_RenderDrawLine /// \see http://wiki.libsdl.org/SDL_RenderDrawLine
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void DrawLine(const Point& p1, const Point& p2); Renderer& DrawLine(const Point& p1, const Point& p2);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Draw a polyline on the current rendering target /// \brief Draw a polyline on the current rendering target
@ -345,12 +371,14 @@ public:
/// \param[in] points Array of coordinates of points along the polyline /// \param[in] points Array of coordinates of points along the polyline
/// \param[in] count Number of points to draw count-1 polyline segments /// \param[in] count Number of points to draw count-1 polyline segments
/// ///
/// \returns Reference to self
///
/// \throws SDL2pp::Exception /// \throws SDL2pp::Exception
/// ///
/// \see http://wiki.libsdl.org/SDL_RenderDrawLines /// \see http://wiki.libsdl.org/SDL_RenderDrawLines
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void DrawLines(const Point* points, int count); Renderer& DrawLines(const Point* points, int count);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Draw a rectangle on the current rendering target /// \brief Draw a rectangle on the current rendering target
@ -360,12 +388,14 @@ public:
/// \param[in] x2 X coordinate of the end corner /// \param[in] x2 X coordinate of the end corner
/// \param[in] y2 Y coordinate of the end corner /// \param[in] y2 Y coordinate of the end corner
/// ///
/// \returns Reference to self
///
/// \throws SDL2pp::Exception /// \throws SDL2pp::Exception
/// ///
/// \see http://wiki.libsdl.org/SDL_RenderDrawRect /// \see http://wiki.libsdl.org/SDL_RenderDrawRect
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void DrawRect(int x1, int y1, int x2, int y2); Renderer& DrawRect(int x1, int y1, int x2, int y2);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Draw a rectangle on the current rendering target /// \brief Draw a rectangle on the current rendering target
@ -373,24 +403,28 @@ public:
/// \param[in] p1 Coordinates of the start corner /// \param[in] p1 Coordinates of the start corner
/// \param[in] p2 Coordinates of the end corner /// \param[in] p2 Coordinates of the end corner
/// ///
/// \returns Reference to self
///
/// \throws SDL2pp::Exception /// \throws SDL2pp::Exception
/// ///
/// \see http://wiki.libsdl.org/SDL_RenderDrawRect /// \see http://wiki.libsdl.org/SDL_RenderDrawRect
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void DrawRect(const Point& p1, const Point& p2); Renderer& DrawRect(const Point& p1, const Point& p2);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Draw a rectangle on the current rendering target /// \brief Draw a rectangle on the current rendering target
/// ///
/// \param[in] r Rectangle to draw /// \param[in] r Rectangle to draw
/// ///
/// \returns Reference to self
///
/// \throws SDL2pp::Exception /// \throws SDL2pp::Exception
/// ///
/// \see http://wiki.libsdl.org/SDL_RenderDrawRect /// \see http://wiki.libsdl.org/SDL_RenderDrawRect
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void DrawRect(const Rect& r); Renderer& DrawRect(const Rect& r);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Draw multiple rectangles on the current rendering target /// \brief Draw multiple rectangles on the current rendering target
@ -398,12 +432,14 @@ public:
/// \param[in] rects Array of rectangles to draw /// \param[in] rects Array of rectangles to draw
/// \param[in] count Number of rectangles /// \param[in] count Number of rectangles
/// ///
/// \returns Reference to self
///
/// \throws SDL2pp::Exception /// \throws SDL2pp::Exception
/// ///
/// \see http://wiki.libsdl.org/SDL_RenderDrawRects /// \see http://wiki.libsdl.org/SDL_RenderDrawRects
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void DrawRects(const Rect* rects, int count); Renderer& DrawRects(const Rect* rects, int count);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Fill a rectangle on the current rendering target /// \brief Fill a rectangle on the current rendering target
@ -413,12 +449,14 @@ public:
/// \param[in] x2 X coordinate of the end corner /// \param[in] x2 X coordinate of the end corner
/// \param[in] y2 Y coordinate of the end corner /// \param[in] y2 Y coordinate of the end corner
/// ///
/// \returns Reference to self
///
/// \throws SDL2pp::Exception /// \throws SDL2pp::Exception
/// ///
/// \see http://wiki.libsdl.org/SDL_RenderFillRect /// \see http://wiki.libsdl.org/SDL_RenderFillRect
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void FillRect(int x1, int y1, int x2, int y2); Renderer& FillRect(int x1, int y1, int x2, int y2);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Fill a rectangle on the current rendering target /// \brief Fill a rectangle on the current rendering target
@ -426,24 +464,28 @@ public:
/// \param[in] p1 Coordinates of the start corner /// \param[in] p1 Coordinates of the start corner
/// \param[in] p2 Coordinates of the end corner /// \param[in] p2 Coordinates of the end corner
/// ///
/// \returns Reference to self
///
/// \throws SDL2pp::Exception /// \throws SDL2pp::Exception
/// ///
/// \see http://wiki.libsdl.org/SDL_RenderFillRect /// \see http://wiki.libsdl.org/SDL_RenderFillRect
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void FillRect(const Point& p1, const Point& p2); Renderer& FillRect(const Point& p1, const Point& p2);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Fill a rectangle on the current rendering target /// \brief Fill a rectangle on the current rendering target
/// ///
/// \param[in] r Rectangle to draw /// \param[in] r Rectangle to draw
/// ///
/// \returns Reference to self
///
/// \throws SDL2pp::Exception /// \throws SDL2pp::Exception
/// ///
/// \see http://wiki.libsdl.org/SDL_RenderFillRect /// \see http://wiki.libsdl.org/SDL_RenderFillRect
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void FillRect(const Rect& r); Renderer& FillRect(const Rect& r);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Fill multiple rectangles on the current rendering target /// \brief Fill multiple rectangles on the current rendering target
@ -451,12 +493,14 @@ public:
/// \param[in] rects Array of rectangles to draw /// \param[in] rects Array of rectangles to draw
/// \param[in] count Number of rectangles /// \param[in] count Number of rectangles
/// ///
/// \returns Reference to self
///
/// \throws SDL2pp::Exception /// \throws SDL2pp::Exception
/// ///
/// \see http://wiki.libsdl.org/SDL_RenderFillRects /// \see http://wiki.libsdl.org/SDL_RenderFillRects
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void FillRects(const Rect* rects, int count); Renderer& FillRects(const Rect* rects, int count);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Read pixels from the current rendering target /// \brief Read pixels from the current rendering target
@ -483,12 +527,14 @@ public:
/// \param[in] rect New clipping rectangle or NullOpt to disable /// \param[in] rect New clipping rectangle or NullOpt to disable
/// clipping /// clipping
/// ///
/// \returns Reference to self
///
/// \throws SDL2pp::Exception /// \throws SDL2pp::Exception
/// ///
/// \see http://wiki.libsdl.org/SDL_RenderSetClipRect /// \see http://wiki.libsdl.org/SDL_RenderSetClipRect
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void SetClipRect(const Optional<Rect>& rect = NullOpt); Renderer& SetClipRect(const Optional<Rect>& rect = NullOpt);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Set a device independent resolution for rendering /// \brief Set a device independent resolution for rendering
@ -496,12 +542,14 @@ public:
/// \param[in] w Width of the logical resolution /// \param[in] w Width of the logical resolution
/// \param[in] h Height of the logical resolution /// \param[in] h Height of the logical resolution
/// ///
/// \returns Reference to self
///
/// \throws SDL2pp::Exception /// \throws SDL2pp::Exception
/// ///
/// \see http://wiki.libsdl.org/SDL_RenderSetLogicalSize /// \see http://wiki.libsdl.org/SDL_RenderSetLogicalSize
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void SetLogicalSize(int w, int h); Renderer& SetLogicalSize(int w, int h);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Set the drawing scale for rendering on the current target /// \brief Set the drawing scale for rendering on the current target
@ -509,12 +557,14 @@ public:
/// \param[in] scaleX Horizontal scaling factor /// \param[in] scaleX Horizontal scaling factor
/// \param[in] scaleY Vertical scaling factor /// \param[in] scaleY Vertical scaling factor
/// ///
/// \returns Reference to self
///
/// \throws SDL2pp::Exception /// \throws SDL2pp::Exception
/// ///
/// \see http://wiki.libsdl.org/SDL_RenderSetScale /// \see http://wiki.libsdl.org/SDL_RenderSetScale
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void SetScale(float scaleX, float scaleY); Renderer& SetScale(float scaleX, float scaleY);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Set the drawing area for rendering on the current target /// \brief Set the drawing area for rendering on the current target
@ -522,12 +572,14 @@ public:
/// \param[in] rect Rectangle representing the drawing area or /// \param[in] rect Rectangle representing the drawing area or
/// NullOpt to set the viewport to the entire target /// NullOpt to set the viewport to the entire target
/// ///
/// \returns Reference to self
///
/// \throws SDL2pp::Exception /// \throws SDL2pp::Exception
/// ///
/// \see http://wiki.libsdl.org/SDL_RenderSetViewport /// \see http://wiki.libsdl.org/SDL_RenderSetViewport
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void SetViewport(const Optional<Rect>& rect = NullOpt); Renderer& SetViewport(const Optional<Rect>& rect = NullOpt);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// \brief Determine whether a window supports the use of /// \brief Determine whether a window supports the use of