2022-07-25 14:36:05 +08:00
|
|
|
#include <SFML/Graphics/RenderTexture.hpp>
|
|
|
|
|
2023-09-02 06:42:47 +08:00
|
|
|
#include <catch2/catch_test_macros.hpp>
|
|
|
|
|
|
|
|
#include <WindowUtil.hpp>
|
2022-07-25 14:36:05 +08:00
|
|
|
#include <type_traits>
|
|
|
|
|
2023-09-02 06:42:47 +08:00
|
|
|
TEST_CASE("[Graphics] sf::RenderTexture", runDisplayTests())
|
|
|
|
{
|
|
|
|
SECTION("Type traits")
|
|
|
|
{
|
|
|
|
STATIC_CHECK(!std::is_copy_constructible_v<sf::RenderTexture>);
|
|
|
|
STATIC_CHECK(!std::is_copy_assignable_v<sf::RenderTexture>);
|
2023-06-07 06:12:44 +08:00
|
|
|
STATIC_CHECK(std::is_nothrow_move_constructible_v<sf::RenderTexture>);
|
|
|
|
STATIC_CHECK(std::is_nothrow_move_assignable_v<sf::RenderTexture>);
|
2023-09-02 06:42:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("Construction")
|
|
|
|
{
|
|
|
|
const sf::RenderTexture renderTexture;
|
|
|
|
CHECK(!renderTexture.isSmooth());
|
|
|
|
CHECK(!renderTexture.isRepeated());
|
|
|
|
CHECK(renderTexture.getSize() == sf::Vector2u(0, 0));
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("create()")
|
|
|
|
{
|
|
|
|
sf::RenderTexture renderTexture;
|
|
|
|
CHECK(!renderTexture.create({1'000'000, 1'000'000}));
|
|
|
|
CHECK(renderTexture.create({480, 360}));
|
|
|
|
CHECK(!renderTexture.isSmooth());
|
|
|
|
CHECK(!renderTexture.isRepeated());
|
|
|
|
CHECK(renderTexture.getSize() == sf::Vector2u(480, 360));
|
|
|
|
CHECK(!renderTexture.isSrgb());
|
2015-04-29 11:28:02 +08:00
|
|
|
CHECK(renderTexture.create({360, 480}));
|
|
|
|
CHECK(renderTexture.getSize() == sf::Vector2u(360, 480));
|
|
|
|
CHECK(renderTexture.create({100, 100}, sf::ContextSettings(8, 0)));
|
|
|
|
CHECK(renderTexture.create({100, 100}, sf::ContextSettings(0, 8)));
|
2023-09-02 06:42:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("getMaximumAntialiasingLevel()")
|
|
|
|
{
|
2023-10-28 01:15:43 +08:00
|
|
|
CHECK(sf::RenderTexture::getMaximumAntialiasingLevel() <= 64);
|
2023-09-02 06:42:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("Set/get smooth")
|
|
|
|
{
|
|
|
|
sf::RenderTexture renderTexture;
|
|
|
|
renderTexture.setSmooth(true);
|
|
|
|
CHECK(renderTexture.isSmooth());
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("Set/get repeated")
|
|
|
|
{
|
|
|
|
sf::RenderTexture renderTexture;
|
|
|
|
renderTexture.setRepeated(true);
|
|
|
|
CHECK(renderTexture.isRepeated());
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("generateMipmap()")
|
|
|
|
{
|
|
|
|
sf::RenderTexture renderTexture;
|
|
|
|
CHECK(!renderTexture.generateMipmap());
|
|
|
|
CHECK(renderTexture.create({480, 360}));
|
|
|
|
CHECK(renderTexture.generateMipmap());
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("setActive()")
|
|
|
|
{
|
|
|
|
sf::RenderTexture renderTexture;
|
|
|
|
CHECK(!renderTexture.setActive());
|
|
|
|
CHECK(renderTexture.create({480, 360}));
|
|
|
|
CHECK(renderTexture.setActive());
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("getTexture()")
|
|
|
|
{
|
|
|
|
sf::RenderTexture renderTexture;
|
|
|
|
CHECK(renderTexture.getTexture().getSize() == sf::Vector2u(0, 0));
|
|
|
|
CHECK(renderTexture.create({480, 360}));
|
|
|
|
CHECK(renderTexture.getTexture().getSize() == sf::Vector2u(480, 360));
|
|
|
|
}
|
|
|
|
}
|