diff --git a/include/SFML/Graphics/Texture.hpp b/include/SFML/Graphics/Texture.hpp index c4df70317..e0a4a9f66 100644 --- a/include/SFML/Graphics/Texture.hpp +++ b/include/SFML/Graphics/Texture.hpp @@ -711,6 +711,14 @@ public: //////////////////////////////////////////////////////////// [[nodiscard]] static unsigned int getMaximumSize(); + //////////////////////////////////////////////////////////// + /// \brief Get the state of whether the Y orientatino of pixels are flipped + /// + /// \return `true` if pixels are flipped, otherwise `false` + /// + //////////////////////////////////////////////////////////// + [[nodiscard]] bool getPixelsFlipped() const; + private: friend class Text; friend class RenderTexture; diff --git a/src/SFML/Graphics/Texture.cpp b/src/SFML/Graphics/Texture.cpp index 9fafb1dd9..cd367c294 100644 --- a/src/SFML/Graphics/Texture.cpp +++ b/src/SFML/Graphics/Texture.cpp @@ -1005,6 +1005,13 @@ unsigned int Texture::getMaximumSize() } +//////////////////////////////////////////////////////////// +bool Texture::getPixelsFlipped() const +{ + return m_pixelsFlipped; +} + + //////////////////////////////////////////////////////////// Texture& Texture::operator=(const Texture& right) { diff --git a/test/Graphics/Texture.test.cpp b/test/Graphics/Texture.test.cpp index e0e175c65..e0870bbbd 100644 --- a/test/Graphics/Texture.test.cpp +++ b/test/Graphics/Texture.test.cpp @@ -131,6 +131,7 @@ TEST_CASE("[Graphics] sf::Texture", runDisplayTests()) CHECK(!texture.isSrgb()); CHECK(!texture.isRepeated()); CHECK(texture.getNativeHandle() == 0); + CHECK(!texture.getPixelsFlipped()); } SECTION("Assignment") @@ -143,6 +144,7 @@ TEST_CASE("[Graphics] sf::Texture", runDisplayTests()) CHECK(!texture.isSrgb()); CHECK(!texture.isRepeated()); CHECK(texture.getNativeHandle() == 0); + CHECK(!texture.getPixelsFlipped()); } } @@ -157,6 +159,7 @@ TEST_CASE("[Graphics] sf::Texture", runDisplayTests()) CHECK(!texture.isSrgb()); CHECK(!texture.isRepeated()); CHECK(texture.getNativeHandle() != 0); + CHECK(!texture.getPixelsFlipped()); } SECTION("Assignment") @@ -169,6 +172,7 @@ TEST_CASE("[Graphics] sf::Texture", runDisplayTests()) CHECK(!texture.isSrgb()); CHECK(!texture.isRepeated()); CHECK(texture.getNativeHandle() != 0); + CHECK(!texture.getPixelsFlipped()); } } @@ -206,6 +210,7 @@ TEST_CASE("[Graphics] sf::Texture", runDisplayTests()) CHECK(!texture.isSrgb()); CHECK(!texture.isRepeated()); CHECK(texture.getNativeHandle() != 0); + CHECK(!texture.getPixelsFlipped()); } SECTION("loadFromMemory()") @@ -218,6 +223,7 @@ TEST_CASE("[Graphics] sf::Texture", runDisplayTests()) CHECK(!texture.isSrgb()); CHECK(!texture.isRepeated()); CHECK(texture.getNativeHandle() != 0); + CHECK(!texture.getPixelsFlipped()); } SECTION("loadFromStream()") @@ -231,6 +237,7 @@ TEST_CASE("[Graphics] sf::Texture", runDisplayTests()) CHECK(!texture.isSrgb()); CHECK(!texture.isRepeated()); CHECK(texture.getNativeHandle() != 0); + CHECK(!texture.getPixelsFlipped()); } SECTION("loadFromImage()") @@ -268,6 +275,7 @@ TEST_CASE("[Graphics] sf::Texture", runDisplayTests()) } CHECK(texture.getNativeHandle() != 0); + CHECK(!texture.getPixelsFlipped()); } } @@ -292,6 +300,8 @@ TEST_CASE("[Graphics] sf::Texture", runDisplayTests()) REQUIRE(textureCopy.getSize() == sf::Vector2u(1, 2)); CHECK(textureCopy.copyToImage().getPixel(sf::Vector2u(0, 1)) == sf::Color::Red); } + + CHECK(!texture.getPixelsFlipped()); } SECTION("update()")