From ddaee362a1c638dc1d699862e825b18b0229b050 Mon Sep 17 00:00:00 2001 From: Vraiment Date: Mon, 3 Jul 2017 21:39:59 -0700 Subject: [PATCH] Added Color support for Renderer --- SDL2pp/Renderer.cc | 10 ++++++++++ SDL2pp/Renderer.hh | 27 +++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/SDL2pp/Renderer.cc b/SDL2pp/Renderer.cc index a3fd63e..fc2ecee 100644 --- a/SDL2pp/Renderer.cc +++ b/SDL2pp/Renderer.cc @@ -197,6 +197,10 @@ Renderer& Renderer::SetDrawColor(Uint8 r, Uint8 g, Uint8 b, Uint8 a) { return *this; } +Renderer& Renderer::SetDrawColor(const Color color) { + return SetDrawColor(color.r, color.g, color.b, color.a); +} + Renderer& Renderer::SetTarget() { if (SDL_SetRenderTarget(renderer_, nullptr) != 0) throw Exception("SDL_SetRenderTarget"); @@ -411,6 +415,12 @@ SDL_BlendMode Renderer::GetDrawBlendMode() const { return mode; } +Color Renderer::GetDrawColor() const { + Color color; + GetDrawColor(color.r, color.g, color.b, color.a); + return color; +} + void Renderer::GetDrawColor(Uint8& r, Uint8& g, Uint8& b, Uint8& a) const { if (SDL_GetRenderDrawColor(renderer_, &r, &g, &b, &a) != 0) throw Exception("SDL_GetRenderDrawColor"); diff --git a/SDL2pp/Renderer.hh b/SDL2pp/Renderer.hh index c89221a..03c2e5c 100644 --- a/SDL2pp/Renderer.hh +++ b/SDL2pp/Renderer.hh @@ -30,6 +30,7 @@ #include #include #include +#include struct SDL_RendererInfo; struct SDL_Renderer; @@ -301,6 +302,20 @@ public: //////////////////////////////////////////////////////////// Renderer& SetDrawColor(Uint8 r = 0, Uint8 g = 0, Uint8 b = 0, Uint8 a = 255); + //////////////////////////////////////////////////////////// + /// \brief Set color user for drawing operations + /// + /// \param[in] color Color to draw on the rendering target + /// + /// \returns Reference to self + /// + /// \throws SDL2pp::Exception + /// + /// \see http://wiki.libsdl.org/SDL_SetRenderDrawColor + /// + //////////////////////////////////////////////////////////// + Renderer& SetDrawColor(const Color color); + //////////////////////////////////////////////////////////// /// \brief Set current render target to default /// @@ -752,6 +767,18 @@ public: //////////////////////////////////////////////////////////// SDL_BlendMode GetDrawBlendMode() const; + //////////////////////////////////////////////////////////// + /// \brief Get the additional color value multiplied into render copy operations + /// + /// \return Color object with the value used to do render copy operations + /// + /// \throws SDL2pp::Exception + /// + /// \see http://wiki.libsdl.org/SDL_GetRenderDrawColor + /// + //////////////////////////////////////////////////////////// + Color GetDrawColor() const; + //////////////////////////////////////////////////////////// /// \brief Get the additional color value multiplied into render copy operations ///