Add getter for sf::Texture::m_pixelsFlipped

This commit is contained in:
Chris Thrasher 2024-10-08 11:48:00 -06:00
parent da1f652c22
commit 4ca8dd117c
No known key found for this signature in database
GPG Key ID: 56FB686C9DFC8E2C
3 changed files with 25 additions and 0 deletions

View File

@ -711,6 +711,14 @@ public:
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
[[nodiscard]] static unsigned int getMaximumSize(); [[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: private:
friend class Text; friend class Text;
friend class RenderTexture; friend class RenderTexture;

View File

@ -1005,6 +1005,13 @@ unsigned int Texture::getMaximumSize()
} }
////////////////////////////////////////////////////////////
bool Texture::getPixelsFlipped() const
{
return m_pixelsFlipped;
}
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Texture& Texture::operator=(const Texture& right) Texture& Texture::operator=(const Texture& right)
{ {

View File

@ -131,6 +131,7 @@ TEST_CASE("[Graphics] sf::Texture", runDisplayTests())
CHECK(!texture.isSrgb()); CHECK(!texture.isSrgb());
CHECK(!texture.isRepeated()); CHECK(!texture.isRepeated());
CHECK(texture.getNativeHandle() == 0); CHECK(texture.getNativeHandle() == 0);
CHECK(!texture.getPixelsFlipped());
} }
SECTION("Assignment") SECTION("Assignment")
@ -143,6 +144,7 @@ TEST_CASE("[Graphics] sf::Texture", runDisplayTests())
CHECK(!texture.isSrgb()); CHECK(!texture.isSrgb());
CHECK(!texture.isRepeated()); CHECK(!texture.isRepeated());
CHECK(texture.getNativeHandle() == 0); CHECK(texture.getNativeHandle() == 0);
CHECK(!texture.getPixelsFlipped());
} }
} }
@ -157,6 +159,7 @@ TEST_CASE("[Graphics] sf::Texture", runDisplayTests())
CHECK(!texture.isSrgb()); CHECK(!texture.isSrgb());
CHECK(!texture.isRepeated()); CHECK(!texture.isRepeated());
CHECK(texture.getNativeHandle() != 0); CHECK(texture.getNativeHandle() != 0);
CHECK(!texture.getPixelsFlipped());
} }
SECTION("Assignment") SECTION("Assignment")
@ -169,6 +172,7 @@ TEST_CASE("[Graphics] sf::Texture", runDisplayTests())
CHECK(!texture.isSrgb()); CHECK(!texture.isSrgb());
CHECK(!texture.isRepeated()); CHECK(!texture.isRepeated());
CHECK(texture.getNativeHandle() != 0); CHECK(texture.getNativeHandle() != 0);
CHECK(!texture.getPixelsFlipped());
} }
} }
@ -206,6 +210,7 @@ TEST_CASE("[Graphics] sf::Texture", runDisplayTests())
CHECK(!texture.isSrgb()); CHECK(!texture.isSrgb());
CHECK(!texture.isRepeated()); CHECK(!texture.isRepeated());
CHECK(texture.getNativeHandle() != 0); CHECK(texture.getNativeHandle() != 0);
CHECK(!texture.getPixelsFlipped());
} }
SECTION("loadFromMemory()") SECTION("loadFromMemory()")
@ -218,6 +223,7 @@ TEST_CASE("[Graphics] sf::Texture", runDisplayTests())
CHECK(!texture.isSrgb()); CHECK(!texture.isSrgb());
CHECK(!texture.isRepeated()); CHECK(!texture.isRepeated());
CHECK(texture.getNativeHandle() != 0); CHECK(texture.getNativeHandle() != 0);
CHECK(!texture.getPixelsFlipped());
} }
SECTION("loadFromStream()") SECTION("loadFromStream()")
@ -231,6 +237,7 @@ TEST_CASE("[Graphics] sf::Texture", runDisplayTests())
CHECK(!texture.isSrgb()); CHECK(!texture.isSrgb());
CHECK(!texture.isRepeated()); CHECK(!texture.isRepeated());
CHECK(texture.getNativeHandle() != 0); CHECK(texture.getNativeHandle() != 0);
CHECK(!texture.getPixelsFlipped());
} }
SECTION("loadFromImage()") SECTION("loadFromImage()")
@ -268,6 +275,7 @@ TEST_CASE("[Graphics] sf::Texture", runDisplayTests())
} }
CHECK(texture.getNativeHandle() != 0); CHECK(texture.getNativeHandle() != 0);
CHECK(!texture.getPixelsFlipped());
} }
} }
@ -292,6 +300,8 @@ TEST_CASE("[Graphics] sf::Texture", runDisplayTests())
REQUIRE(textureCopy.getSize() == sf::Vector2u(1, 2)); REQUIRE(textureCopy.getSize() == sf::Vector2u(1, 2));
CHECK(textureCopy.copyToImage().getPixel(sf::Vector2u(0, 1)) == sf::Color::Red); CHECK(textureCopy.copyToImage().getPixel(sf::Vector2u(0, 1)) == sf::Color::Red);
} }
CHECK(!texture.getPixelsFlipped());
} }
SECTION("update()") SECTION("update()")