From 49251c31a8e3aba885b85fb97ace358416ea1bf6 Mon Sep 17 00:00:00 2001 From: Vraiment Date: Tue, 4 Jul 2017 09:58:53 -0700 Subject: [PATCH] Addressed comments in pull request #99 --- SDL2pp/Color.cc | 2 +- SDL2pp/Color.hh | 2 +- SDL2pp/Renderer.cc | 2 +- SDL2pp/Renderer.hh | 2 +- SDL2pp/Surface.cc | 6 +++--- SDL2pp/Surface.hh | 4 +++- SDL2pp/Texture.cc | 4 ++-- SDL2pp/Texture.hh | 4 +++- 8 files changed, 15 insertions(+), 11 deletions(-) diff --git a/SDL2pp/Color.cc b/SDL2pp/Color.cc index 7950859..7c2f484 100644 --- a/SDL2pp/Color.cc +++ b/SDL2pp/Color.cc @@ -1,6 +1,6 @@ /* libSDL2pp - C++11 bindings/wrapper for SDL2 - Copyright (C) 2013-2015 Dmitry Marakasov + Copyright (C) 2017 Vraiment This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/SDL2pp/Color.hh b/SDL2pp/Color.hh index 0971ff7..5bd6e80 100644 --- a/SDL2pp/Color.hh +++ b/SDL2pp/Color.hh @@ -1,6 +1,6 @@ /* libSDL2pp - C++11 bindings/wrapper for SDL2 - Copyright (C) 2013-2015 Dmitry Marakasov + Copyright (C) 2017 Vraiment This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/SDL2pp/Renderer.cc b/SDL2pp/Renderer.cc index fc2ecee..86b4df8 100644 --- a/SDL2pp/Renderer.cc +++ b/SDL2pp/Renderer.cc @@ -197,7 +197,7 @@ Renderer& Renderer::SetDrawColor(Uint8 r, Uint8 g, Uint8 b, Uint8 a) { return *this; } -Renderer& Renderer::SetDrawColor(const Color color) { +Renderer& Renderer::SetDrawColor(const Color& color) { return SetDrawColor(color.r, color.g, color.b, color.a); } diff --git a/SDL2pp/Renderer.hh b/SDL2pp/Renderer.hh index 03c2e5c..a8209e5 100644 --- a/SDL2pp/Renderer.hh +++ b/SDL2pp/Renderer.hh @@ -314,7 +314,7 @@ public: /// \see http://wiki.libsdl.org/SDL_SetRenderDrawColor /// //////////////////////////////////////////////////////////// - Renderer& SetDrawColor(const Color color); + Renderer& SetDrawColor(const Color& color); //////////////////////////////////////////////////////////// /// \brief Set current render target to default diff --git a/SDL2pp/Surface.cc b/SDL2pp/Surface.cc index 5aa6434..7babeaf 100644 --- a/SDL2pp/Surface.cc +++ b/SDL2pp/Surface.cc @@ -147,8 +147,8 @@ SDL_BlendMode Surface::GetBlendMode() const { Color Surface::GetColorAndAlphaMod() const { Color color; - GetColorMod(color.r, color.g, color.b); - color.SetAlpha(GetAlphaMod()); + GetColorMod(color.r, color.g, color.b); + color.a = GetAlphaMod(); return color; } @@ -187,7 +187,7 @@ Surface& Surface::SetColorMod(Uint8 r, Uint8 g, Uint8 b) { return *this; } -Surface& Surface::SetColorAndAlphaMod(const Color color) { +Surface& Surface::SetColorAndAlphaMod(const Color& color) { return SetColorMod(color.r, color.g, color.b).SetAlphaMod(color.a); } diff --git a/SDL2pp/Surface.hh b/SDL2pp/Surface.hh index 3b18bc5..7cacfdb 100644 --- a/SDL2pp/Surface.hh +++ b/SDL2pp/Surface.hh @@ -398,6 +398,7 @@ public: /// /// \throws SDL2pp::Exception /// + /// \see http://wiki.libsdl.org/SDL_GetSurfaceAlphaMod /// \see http://wiki.libsdl.org/SDL_GetSurfaceColorMod /// //////////////////////////////////////////////////////////// @@ -499,10 +500,11 @@ public: /// /// \throws SDL2pp::Exception /// + /// \see http://wiki.libsdl.org/SDL_SetSurfaceAlphaMod /// \see http://wiki.libsdl.org/SDL_SetSurfaceColorMod /// //////////////////////////////////////////////////////////// - Surface& SetColorAndAlphaMod(const Color color); + Surface& SetColorAndAlphaMod(const Color& color); //////////////////////////////////////////////////////////// /// \brief Set the RLE acceleration hint for a surface diff --git a/SDL2pp/Texture.cc b/SDL2pp/Texture.cc index 282d935..9218e2a 100644 --- a/SDL2pp/Texture.cc +++ b/SDL2pp/Texture.cc @@ -157,7 +157,7 @@ Texture& Texture::SetColorMod(Uint8 r, Uint8 g, Uint8 b) { return *this; } -Texture& Texture::SetColorAndAlphaMod(const Color color) { +Texture& Texture::SetColorAndAlphaMod(const Color& color) { return SetColorMod(color.r, color.g, color.b).SetAlphaMod(color.a); } @@ -222,7 +222,7 @@ void Texture::GetColorMod(Uint8& r, Uint8& g, Uint8& b) const { Color Texture::GetColorAndAlphaMod() const { Color color; GetColorMod(color.r, color.g, color.b); - color.SetAlpha(GetAlphaMod()); + color.a = GetAlphaMod(); return color; } diff --git a/SDL2pp/Texture.hh b/SDL2pp/Texture.hh index 35818aa..70f947d 100644 --- a/SDL2pp/Texture.hh +++ b/SDL2pp/Texture.hh @@ -431,10 +431,11 @@ public: /// /// \throws SDL2pp::Exception /// + /// \see http://wiki.libsdl.org/SDL_SetTextureAlphaMod /// \see http://wiki.libsdl.org/SDL_SetTextureColorMod /// //////////////////////////////////////////////////////////// - Texture& SetColorAndAlphaMod(const Color color = Color{255, 255, 255, 255}); + Texture& SetColorAndAlphaMod(const Color& color = Color{255, 255, 255, SDL_ALPHA_OPAQUE}); //////////////////////////////////////////////////////////// /// \brief Lock texture for write-only pixel access @@ -559,6 +560,7 @@ public: /// /// \throws SDL2pp::Exception /// + /// \see http://wiki.libsdl.org/SDL_GetTextureAlphaMod /// \see http://wiki.libsdl.org/SDL_GetTextureColorMod /// ////////////////////////////////////////////////////////////