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")
|
|
|
|
{
|
2024-05-22 05:12:13 +08:00
|
|
|
STATIC_CHECK(!std::is_default_constructible_v<sf::RenderTexture>);
|
2023-09-02 06:42:47 +08:00
|
|
|
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("create()")
|
|
|
|
{
|
2024-05-22 05:12:13 +08:00
|
|
|
CHECK(!sf::RenderTexture::create({1'000'000, 1'000'000}));
|
|
|
|
|
2024-05-25 02:36:42 +08:00
|
|
|
CHECK(sf::RenderTexture::create({100, 100}, sf::ContextSettings{8 /* depthBits */, 0 /* stencilBits */}));
|
|
|
|
CHECK(sf::RenderTexture::create({100, 100}, sf::ContextSettings{0 /* depthBits */, 8 /* stencilBits */}));
|
2024-05-22 05:12:13 +08:00
|
|
|
|
|
|
|
const auto renderTexture = sf::RenderTexture::create({360, 480}).value();
|
|
|
|
CHECK(renderTexture.getSize() == sf::Vector2u(360, 480));
|
2023-09-02 06:42:47 +08:00
|
|
|
CHECK(!renderTexture.isSmooth());
|
|
|
|
CHECK(!renderTexture.isRepeated());
|
|
|
|
CHECK(!renderTexture.isSrgb());
|
2024-05-25 02:36:42 +08:00
|
|
|
|
2024-05-22 05:12:13 +08:00
|
|
|
const auto& texture = renderTexture.getTexture();
|
|
|
|
CHECK(texture.getSize() == sf::Vector2u(360, 480));
|
|
|
|
CHECK(!texture.isSmooth());
|
|
|
|
CHECK(!texture.isSrgb());
|
|
|
|
CHECK(!texture.isRepeated());
|
|
|
|
CHECK(texture.getNativeHandle() != 0);
|
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")
|
|
|
|
{
|
2024-05-22 05:12:13 +08:00
|
|
|
auto renderTexture = sf::RenderTexture::create({64, 64}).value();
|
2023-09-02 06:42:47 +08:00
|
|
|
renderTexture.setSmooth(true);
|
|
|
|
CHECK(renderTexture.isSmooth());
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("Set/get repeated")
|
|
|
|
{
|
2024-05-22 05:12:13 +08:00
|
|
|
auto renderTexture = sf::RenderTexture::create({64, 64}).value();
|
2023-09-02 06:42:47 +08:00
|
|
|
renderTexture.setRepeated(true);
|
|
|
|
CHECK(renderTexture.isRepeated());
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("generateMipmap()")
|
|
|
|
{
|
2024-05-22 05:12:13 +08:00
|
|
|
auto renderTexture = sf::RenderTexture::create({64, 64}).value();
|
2023-09-02 06:42:47 +08:00
|
|
|
CHECK(renderTexture.generateMipmap());
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("setActive()")
|
|
|
|
{
|
2024-05-22 05:12:13 +08:00
|
|
|
auto renderTexture = sf::RenderTexture::create({64, 64}).value();
|
2023-09-02 06:42:47 +08:00
|
|
|
CHECK(renderTexture.setActive());
|
2024-05-22 05:12:13 +08:00
|
|
|
CHECK(renderTexture.setActive(false));
|
|
|
|
CHECK(renderTexture.setActive(true));
|
2023-09-02 06:42:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("getTexture()")
|
|
|
|
{
|
2024-05-22 05:12:13 +08:00
|
|
|
const auto renderTexture = sf::RenderTexture::create({64, 64}).value();
|
|
|
|
CHECK(renderTexture.getTexture().getSize() == sf::Vector2u(64, 64));
|
2023-09-02 06:42:47 +08:00
|
|
|
}
|
|
|
|
}
|