From ea43fbbbd7a9368f8c82faf1e6069eda7ae8741d Mon Sep 17 00:00:00 2001 From: Vraiment Date: Mon, 3 Jul 2017 21:09:25 -0700 Subject: [PATCH 01/18] Added Color class --- SDL2pp/Color.cc | 6 +++--- SDL2pp/Color.hh | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/SDL2pp/Color.cc b/SDL2pp/Color.cc index 1807eff..7950859 100644 --- a/SDL2pp/Color.cc +++ b/SDL2pp/Color.cc @@ -1,6 +1,6 @@ /* libSDL2pp - C++11 bindings/wrapper for SDL2 - Copyright (C) 2017 Vraiment + Copyright (C) 2013-2015 Dmitry Marakasov This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -22,6 +22,6 @@ #include std::ostream& operator<<(std::ostream& stream, const SDL2pp::Color& color) { - stream << "[r:" << static_cast(color.r) << ",g:" << static_cast(color.g) << ",b:" << static_cast(color.b) << ",a:" << static_cast(color.a) << "]"; - return stream; + stream << "[r:" << static_cast(color.r) << ",g:" << static_cast(color.g) << ",b:" << static_cast(color.b) << ",a:" << static_cast(color.a) << "]"; + return stream; } diff --git a/SDL2pp/Color.hh b/SDL2pp/Color.hh index 5bd6e80..0971ff7 100644 --- a/SDL2pp/Color.hh +++ b/SDL2pp/Color.hh @@ -1,6 +1,6 @@ /* libSDL2pp - C++11 bindings/wrapper for SDL2 - Copyright (C) 2017 Vraiment + Copyright (C) 2013-2015 Dmitry Marakasov This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages From f9fa7a9d034bb4ff40b0c734bf5b1d48f2719f26 Mon Sep 17 00:00:00 2001 From: Vraiment Date: Mon, 3 Jul 2017 21:39:59 -0700 Subject: [PATCH 02/18] Added Color support for Renderer --- SDL2pp/Renderer.cc | 4 ++-- SDL2pp/Renderer.hh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/SDL2pp/Renderer.cc b/SDL2pp/Renderer.cc index 7efb4b9..fc2ecee 100644 --- a/SDL2pp/Renderer.cc +++ b/SDL2pp/Renderer.cc @@ -197,8 +197,8 @@ 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::SetDrawColor(const Color color) { + return SetDrawColor(color.r, color.g, color.b, color.a); } Renderer& Renderer::SetTarget() { diff --git a/SDL2pp/Renderer.hh b/SDL2pp/Renderer.hh index a8209e5..03c2e5c 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 From ae24c0dd7615d7f8a765fd7d76d7060b09e16ac4 Mon Sep 17 00:00:00 2001 From: Vraiment Date: Mon, 3 Jul 2017 21:50:49 -0700 Subject: [PATCH 03/18] Added Color support for Surface --- SDL2pp/Surface.cc | 6 +++--- SDL2pp/Surface.hh | 4 +--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/SDL2pp/Surface.cc b/SDL2pp/Surface.cc index 7babeaf..5aa6434 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.a = GetAlphaMod(); + GetColorMod(color.r, color.g, color.b); + color.SetAlpha(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 7cacfdb..3b18bc5 100644 --- a/SDL2pp/Surface.hh +++ b/SDL2pp/Surface.hh @@ -398,7 +398,6 @@ public: /// /// \throws SDL2pp::Exception /// - /// \see http://wiki.libsdl.org/SDL_GetSurfaceAlphaMod /// \see http://wiki.libsdl.org/SDL_GetSurfaceColorMod /// //////////////////////////////////////////////////////////// @@ -500,11 +499,10 @@ 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 From 6a3245cf634ac1a2beff61bf43f65d8781a98d0f Mon Sep 17 00:00:00 2001 From: Vraiment Date: Mon, 3 Jul 2017 22:30:39 -0700 Subject: [PATCH 04/18] Added Color support for Texture --- SDL2pp/Texture.cc | 4 ++-- SDL2pp/Texture.hh | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/SDL2pp/Texture.cc b/SDL2pp/Texture.cc index 9218e2a..282d935 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.a = GetAlphaMod(); + color.SetAlpha(GetAlphaMod()); return color; } diff --git a/SDL2pp/Texture.hh b/SDL2pp/Texture.hh index 70f947d..35818aa 100644 --- a/SDL2pp/Texture.hh +++ b/SDL2pp/Texture.hh @@ -431,11 +431,10 @@ 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, SDL_ALPHA_OPAQUE}); + Texture& SetColorAndAlphaMod(const Color color = Color{255, 255, 255, 255}); //////////////////////////////////////////////////////////// /// \brief Lock texture for write-only pixel access @@ -560,7 +559,6 @@ public: /// /// \throws SDL2pp::Exception /// - /// \see http://wiki.libsdl.org/SDL_GetTextureAlphaMod /// \see http://wiki.libsdl.org/SDL_GetTextureColorMod /// //////////////////////////////////////////////////////////// From d4429244ffe40bc4a59e66a707cd3fc90828d3eb Mon Sep 17 00:00:00 2001 From: Vraiment Date: Tue, 4 Jul 2017 09:58:53 -0700 Subject: [PATCH 05/18] 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 /// //////////////////////////////////////////////////////////// From c9489fb18253e79c18c9a993598c4a8212a12aeb Mon Sep 17 00:00:00 2001 From: Dmitry Marakasov Date: Fri, 7 Jul 2017 22:13:14 +0300 Subject: [PATCH 06/18] Add Color tests --- tests/test_color_constexpr.cc | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/test_color_constexpr.cc b/tests/test_color_constexpr.cc index 0d0a028..a672956 100644 --- a/tests/test_color_constexpr.cc +++ b/tests/test_color_constexpr.cc @@ -24,6 +24,4 @@ int main(int, char*[]) { constexpr int a = c1.GetAlpha(); static_assert(r == 0 && g == 0 && b == 0 && a == 0, ""); - - return 0; } From b173ec20eba0d75f856873b715ab146c0779751d Mon Sep 17 00:00:00 2001 From: Dmitry Marakasov Date: Fri, 7 Jul 2017 22:26:54 +0300 Subject: [PATCH 07/18] Since this is constexpr test, use static_asserts --- tests/test_pointrect_constexpr.cc | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/test_pointrect_constexpr.cc b/tests/test_pointrect_constexpr.cc index 179678a..ef2a6a4 100644 --- a/tests/test_pointrect_constexpr.cc +++ b/tests/test_pointrect_constexpr.cc @@ -77,6 +77,4 @@ int main(int, char*[]) { static_assert(b3 && b4 && b5 && b6, ""); } - - return 0; } From 1d5174b845f779e4ccd7d28d15e2a9097eba39ba Mon Sep 17 00:00:00 2001 From: Dmitry Marakasov Date: Fri, 7 Jul 2017 22:38:22 +0300 Subject: [PATCH 08/18] Whitespace fixes --- SDL2pp/Color.cc | 4 ++-- SDL2pp/Renderer.cc | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/SDL2pp/Color.cc b/SDL2pp/Color.cc index 7c2f484..1807eff 100644 --- a/SDL2pp/Color.cc +++ b/SDL2pp/Color.cc @@ -22,6 +22,6 @@ #include std::ostream& operator<<(std::ostream& stream, const SDL2pp::Color& color) { - stream << "[r:" << static_cast(color.r) << ",g:" << static_cast(color.g) << ",b:" << static_cast(color.b) << ",a:" << static_cast(color.a) << "]"; - return stream; + stream << "[r:" << static_cast(color.r) << ",g:" << static_cast(color.g) << ",b:" << static_cast(color.b) << ",a:" << static_cast(color.a) << "]"; + return stream; } diff --git a/SDL2pp/Renderer.cc b/SDL2pp/Renderer.cc index 86b4df8..7efb4b9 100644 --- a/SDL2pp/Renderer.cc +++ b/SDL2pp/Renderer.cc @@ -198,7 +198,7 @@ Renderer& Renderer::SetDrawColor(Uint8 r, Uint8 g, Uint8 b, Uint8 a) { } Renderer& Renderer::SetDrawColor(const Color& color) { - return SetDrawColor(color.r, color.g, color.b, color.a); + return SetDrawColor(color.r, color.g, color.b, color.a); } Renderer& Renderer::SetTarget() { From 9b2e860d186bbc32e6a13296596ea9c27922f6f8 Mon Sep 17 00:00:00 2001 From: Dmitry Marakasov Date: Tue, 11 Jul 2017 17:47:40 +0300 Subject: [PATCH 09/18] Add returns to constexpr tests These are needed since main() is actually replaced with SDL_main() --- tests/test_color_constexpr.cc | 2 ++ tests/test_pointrect_constexpr.cc | 2 ++ 2 files changed, 4 insertions(+) diff --git a/tests/test_color_constexpr.cc b/tests/test_color_constexpr.cc index a672956..0d0a028 100644 --- a/tests/test_color_constexpr.cc +++ b/tests/test_color_constexpr.cc @@ -24,4 +24,6 @@ int main(int, char*[]) { constexpr int a = c1.GetAlpha(); static_assert(r == 0 && g == 0 && b == 0 && a == 0, ""); + + return 0; } diff --git a/tests/test_pointrect_constexpr.cc b/tests/test_pointrect_constexpr.cc index ef2a6a4..179678a 100644 --- a/tests/test_pointrect_constexpr.cc +++ b/tests/test_pointrect_constexpr.cc @@ -77,4 +77,6 @@ int main(int, char*[]) { static_assert(b3 && b4 && b5 && b6, ""); } + + return 0; } From c6b98ea051a3c0f7e80c11aa8ea3e405d455fde5 Mon Sep 17 00:00:00 2001 From: Vraiment Date: Mon, 3 Jul 2017 21:09:25 -0700 Subject: [PATCH 10/18] Added Color class --- SDL2pp/Color.cc | 6 +++--- SDL2pp/Color.hh | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/SDL2pp/Color.cc b/SDL2pp/Color.cc index 1807eff..7950859 100644 --- a/SDL2pp/Color.cc +++ b/SDL2pp/Color.cc @@ -1,6 +1,6 @@ /* libSDL2pp - C++11 bindings/wrapper for SDL2 - Copyright (C) 2017 Vraiment + Copyright (C) 2013-2015 Dmitry Marakasov This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -22,6 +22,6 @@ #include std::ostream& operator<<(std::ostream& stream, const SDL2pp::Color& color) { - stream << "[r:" << static_cast(color.r) << ",g:" << static_cast(color.g) << ",b:" << static_cast(color.b) << ",a:" << static_cast(color.a) << "]"; - return stream; + stream << "[r:" << static_cast(color.r) << ",g:" << static_cast(color.g) << ",b:" << static_cast(color.b) << ",a:" << static_cast(color.a) << "]"; + return stream; } diff --git a/SDL2pp/Color.hh b/SDL2pp/Color.hh index 5bd6e80..0971ff7 100644 --- a/SDL2pp/Color.hh +++ b/SDL2pp/Color.hh @@ -1,6 +1,6 @@ /* libSDL2pp - C++11 bindings/wrapper for SDL2 - Copyright (C) 2017 Vraiment + Copyright (C) 2013-2015 Dmitry Marakasov This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages From b0f09dac4e1101ed34d04cd4efbc2e58051ae9e1 Mon Sep 17 00:00:00 2001 From: Vraiment Date: Mon, 3 Jul 2017 21:39:59 -0700 Subject: [PATCH 11/18] Added Color support for Renderer --- SDL2pp/Renderer.cc | 4 ++-- SDL2pp/Renderer.hh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/SDL2pp/Renderer.cc b/SDL2pp/Renderer.cc index 7efb4b9..fc2ecee 100644 --- a/SDL2pp/Renderer.cc +++ b/SDL2pp/Renderer.cc @@ -197,8 +197,8 @@ 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::SetDrawColor(const Color color) { + return SetDrawColor(color.r, color.g, color.b, color.a); } Renderer& Renderer::SetTarget() { diff --git a/SDL2pp/Renderer.hh b/SDL2pp/Renderer.hh index a8209e5..03c2e5c 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 From c9684f03d39a31d0ceac29fd0b9322de47a8027b Mon Sep 17 00:00:00 2001 From: Vraiment Date: Mon, 3 Jul 2017 21:50:49 -0700 Subject: [PATCH 12/18] Added Color support for Surface --- SDL2pp/Surface.cc | 6 +++--- SDL2pp/Surface.hh | 4 +--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/SDL2pp/Surface.cc b/SDL2pp/Surface.cc index 7babeaf..5aa6434 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.a = GetAlphaMod(); + GetColorMod(color.r, color.g, color.b); + color.SetAlpha(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 7cacfdb..3b18bc5 100644 --- a/SDL2pp/Surface.hh +++ b/SDL2pp/Surface.hh @@ -398,7 +398,6 @@ public: /// /// \throws SDL2pp::Exception /// - /// \see http://wiki.libsdl.org/SDL_GetSurfaceAlphaMod /// \see http://wiki.libsdl.org/SDL_GetSurfaceColorMod /// //////////////////////////////////////////////////////////// @@ -500,11 +499,10 @@ 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 From 2379a402d9246ad73ba792e587e557a710ea7040 Mon Sep 17 00:00:00 2001 From: Vraiment Date: Mon, 3 Jul 2017 22:30:39 -0700 Subject: [PATCH 13/18] Added Color support for Texture --- SDL2pp/Texture.cc | 4 ++-- SDL2pp/Texture.hh | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/SDL2pp/Texture.cc b/SDL2pp/Texture.cc index 9218e2a..282d935 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.a = GetAlphaMod(); + color.SetAlpha(GetAlphaMod()); return color; } diff --git a/SDL2pp/Texture.hh b/SDL2pp/Texture.hh index 70f947d..35818aa 100644 --- a/SDL2pp/Texture.hh +++ b/SDL2pp/Texture.hh @@ -431,11 +431,10 @@ 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, SDL_ALPHA_OPAQUE}); + Texture& SetColorAndAlphaMod(const Color color = Color{255, 255, 255, 255}); //////////////////////////////////////////////////////////// /// \brief Lock texture for write-only pixel access @@ -560,7 +559,6 @@ public: /// /// \throws SDL2pp::Exception /// - /// \see http://wiki.libsdl.org/SDL_GetTextureAlphaMod /// \see http://wiki.libsdl.org/SDL_GetTextureColorMod /// //////////////////////////////////////////////////////////// From 1281d907a598a252a1de94c334cc8e61f6f9c7ed Mon Sep 17 00:00:00 2001 From: Vraiment Date: Tue, 4 Jul 2017 09:58:53 -0700 Subject: [PATCH 14/18] 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 /// //////////////////////////////////////////////////////////// From fb3c9afbe9bfb6f75b606380c80cc4ca16b3f3bc Mon Sep 17 00:00:00 2001 From: Dmitry Marakasov Date: Fri, 7 Jul 2017 22:13:14 +0300 Subject: [PATCH 15/18] Add Color tests --- tests/test_color_constexpr.cc | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/test_color_constexpr.cc b/tests/test_color_constexpr.cc index 0d0a028..a672956 100644 --- a/tests/test_color_constexpr.cc +++ b/tests/test_color_constexpr.cc @@ -24,6 +24,4 @@ int main(int, char*[]) { constexpr int a = c1.GetAlpha(); static_assert(r == 0 && g == 0 && b == 0 && a == 0, ""); - - return 0; } From 4f4d035837785d4e64a91338cc41fd1d98e242df Mon Sep 17 00:00:00 2001 From: Dmitry Marakasov Date: Fri, 7 Jul 2017 22:26:54 +0300 Subject: [PATCH 16/18] Since this is constexpr test, use static_asserts --- tests/test_pointrect_constexpr.cc | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/test_pointrect_constexpr.cc b/tests/test_pointrect_constexpr.cc index 179678a..ef2a6a4 100644 --- a/tests/test_pointrect_constexpr.cc +++ b/tests/test_pointrect_constexpr.cc @@ -77,6 +77,4 @@ int main(int, char*[]) { static_assert(b3 && b4 && b5 && b6, ""); } - - return 0; } From ab89c9d8fcd3272ed0a930c2673c6a28e6b41acc Mon Sep 17 00:00:00 2001 From: Dmitry Marakasov Date: Fri, 7 Jul 2017 22:38:22 +0300 Subject: [PATCH 17/18] Whitespace fixes --- SDL2pp/Color.cc | 4 ++-- SDL2pp/Renderer.cc | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/SDL2pp/Color.cc b/SDL2pp/Color.cc index 7c2f484..1807eff 100644 --- a/SDL2pp/Color.cc +++ b/SDL2pp/Color.cc @@ -22,6 +22,6 @@ #include std::ostream& operator<<(std::ostream& stream, const SDL2pp::Color& color) { - stream << "[r:" << static_cast(color.r) << ",g:" << static_cast(color.g) << ",b:" << static_cast(color.b) << ",a:" << static_cast(color.a) << "]"; - return stream; + stream << "[r:" << static_cast(color.r) << ",g:" << static_cast(color.g) << ",b:" << static_cast(color.b) << ",a:" << static_cast(color.a) << "]"; + return stream; } diff --git a/SDL2pp/Renderer.cc b/SDL2pp/Renderer.cc index 86b4df8..7efb4b9 100644 --- a/SDL2pp/Renderer.cc +++ b/SDL2pp/Renderer.cc @@ -198,7 +198,7 @@ Renderer& Renderer::SetDrawColor(Uint8 r, Uint8 g, Uint8 b, Uint8 a) { } Renderer& Renderer::SetDrawColor(const Color& color) { - return SetDrawColor(color.r, color.g, color.b, color.a); + return SetDrawColor(color.r, color.g, color.b, color.a); } Renderer& Renderer::SetTarget() { From c5455cc97b82090d2c373a30a890af9044d1d8a4 Mon Sep 17 00:00:00 2001 From: Vraiment Date: Tue, 11 Jul 2017 20:28:31 -0700 Subject: [PATCH 18/18] Added XCode related config --- .gitignore | 3 +++ CMakeLists.txt | 4 ++++ tests/testing.h | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index faccaec..dfb0481 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,9 @@ sdl2pp.pc *.sln Debug/ Win32/ +CMakeScripts/ +*.build +*.xcodeproj # Binaries *.o diff --git a/CMakeLists.txt b/CMakeLists.txt index 51eb91e..1cf2074 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -93,6 +93,10 @@ ELSE(MSVC) #APPEND_CXX_FLAG_IF_SUPPORTED(-Wno-c++98-compat SDL2PP_WARNINGS) #APPEND_CXX_FLAG_IF_SUPPORTED(-Wno-padded SDL2PP_WARNINGS) ENDIF(MSVC) +IF (CMAKE_GENERATOR STREQUAL "Xcode") + # To disable colored output on the XCode test console + ADD_DEFINITIONS(-DSDL2PP_XCODE_GENERATED) +ENDIF (CMAKE_GENERATOR STREQUAL "Xcode") LIST(REMOVE_DUPLICATES SDL2_ALL_INCLUDE_DIRS) diff --git a/tests/testing.h b/tests/testing.h index c9e4651..0d9bf3d 100644 --- a/tests/testing.h +++ b/tests/testing.h @@ -36,7 +36,7 @@ #include #include -#ifdef _WIN32 +#if (defined _WIN32) || (defined SDL2PP_XCODE_GENERATED) # define TESTING_NO_COLOR #endif