From 765cd539feb40b3190acc84522d212bfbdafacae Mon Sep 17 00:00:00 2001 From: Jaby Blubb Date: Wed, 27 Sep 2023 22:09:15 +0200 Subject: [PATCH] Remove Rectangle constructors --- .../PoolBox/application/src/Objects/paco.hpp | 2 +- .../src/Overlay/GPUTests/gpu_tests.cpp | 20 ++++----- .../Primitives/primitive_rectangle_types.hpp | 44 ++++++++++++++----- 3 files changed, 44 insertions(+), 22 deletions(-) diff --git a/examples/PoolBox/application/src/Objects/paco.hpp b/examples/PoolBox/application/src/Objects/paco.hpp index a57c8ba8..f46a7977 100644 --- a/examples/PoolBox/application/src/Objects/paco.hpp +++ b/examples/PoolBox/application/src/Objects/paco.hpp @@ -23,7 +23,7 @@ namespace object { tex_page(GPU::TexPage::create( {TIM.get_texture_x(), TIM.get_texture_y()}, GPU::TexturePageColor::$4bit).linked()), - sprite(GPU::SPRT( + sprite(GPU::SPRT::create( #pragma GCC warning "This pic used to be 122px (file size) and every tool would except it - however the display would be corrupt" GPU::AreaI16({0, 100}, {120, 128}), GPU::PagePositionClut({0, 0}, GPU::PageClut(TIM.get_clut_x(), TIM.get_clut_y())), diff --git a/examples/PoolBox/application/src/Overlay/GPUTests/gpu_tests.cpp b/examples/PoolBox/application/src/Overlay/GPUTests/gpu_tests.cpp index 52a89c90..7b3307de 100644 --- a/examples/PoolBox/application/src/Overlay/GPUTests/gpu_tests.cpp +++ b/examples/PoolBox/application/src/Overlay/GPUTests/gpu_tests.cpp @@ -110,19 +110,19 @@ static constexpr const auto line4 = GPU::LINE_G::create( GPU::ColorVertex{GPU::Color24::White(), {0, 0}} ); -static constexpr const auto rect1 = GPU::TILE(GPU::AreaI16({GPU::Display::Width - 32, GPU::Display::Height - 32}, {32, 32}), GPU::Color24::Green()); -static constexpr const auto rect2 = GPU::TILE_16({GPU::Display::Width - 16, GPU::Display::Height - 16}, GPU::Color24::Blue()); -static constexpr const auto rect3 = GPU::TILE_8({GPU::Display::Width - 8, GPU::Display::Height - 8}, GPU::Color24::Yellow()); -static constexpr const auto rect4 = GPU::TILE_1({GPU::Display::Width - 1, GPU::Display::Height - 1}, GPU::Color24::Red()); +static constexpr const auto rect1 = GPU::TILE::create(GPU::AreaI16({GPU::Display::Width - 32, GPU::Display::Height - 32}, {32, 32}), GPU::Color24::Green()); +static constexpr const auto rect2 = GPU::TILE_16::create({GPU::Display::Width - 16, GPU::Display::Height - 16}, GPU::Color24::Blue()); +static constexpr const auto rect3 = GPU::TILE_8::create({GPU::Display::Width - 8, GPU::Display::Height - 8}, GPU::Color24::Yellow()); +static constexpr const auto rect4 = GPU::TILE_1::create({GPU::Display::Width - 1, GPU::Display::Height - 1}, GPU::Color24::Red()); static constexpr const auto texpage = GPU::TexPage::create({320, 0}, GPU::TexturePageColor::$4bit); -static constexpr const auto rect5 = GPU::SPRT(GPU::AreaI16({0, GPU::Display::Height - 32}, {32, 32}), {{0, 0}, TriangleClut}, GPU::Color24::Green()); -static constexpr const auto rect6 = GPU::SPRT_16({0, GPU::Display::Height - 16}, {{0, 0}, TriangleClut}, GPU::Color24::Blue()); -static constexpr const auto rect7 = GPU::SPRT_8({0, GPU::Display::Height - 8}, {{0, 0}, TriangleClut}, GPU::Color24::Yellow()); -static constexpr const auto rect8 = GPU::SPRT_1({0, GPU::Display::Height - 1}, {{0, 0}, TriangleClut}, GPU::Color24::Red()); +static constexpr const auto rect5 = GPU::SPRT::create(GPU::AreaI16({0, GPU::Display::Height - 32}, {32, 32}), {{0, 0}, TriangleClut}, GPU::Color24::Green()); +static constexpr const auto rect6 = GPU::SPRT_16::create({0, GPU::Display::Height - 16}, {{0, 0}, TriangleClut}, GPU::Color24::Blue()); +static constexpr const auto rect7 = GPU::SPRT_8::create({0, GPU::Display::Height - 8}, {{0, 0}, TriangleClut}, GPU::Color24::Yellow()); +static constexpr const auto rect8 = GPU::SPRT_1::create({0, GPU::Display::Height - 1}, {{0, 0}, TriangleClut}, GPU::Color24::Red()); -static auto rect9 = GPU::SPRT(GPU::AreaI16({GPU::Display::Width/2, GPU::Display::Height/2}, {32, 32}).centered(), {{0, 0}, TriangleClut}, GPU::Color24::Grey()).linked(); -static auto rect10 = GPU::SPRT(GPU::AreaI16({GPU::Display::Width/2, GPU::Display::Height/2 - 32}, {32, 32}).centered(), {{0, 0}, TriangleClut}, GPU::Color24::Grey()).linked(); +static auto rect9 = GPU::SPRT::create(GPU::AreaI16({GPU::Display::Width/2, GPU::Display::Height/2}, {32, 32}).centered(), {{0, 0}, TriangleClut}, GPU::Color24::Grey()).linked(); +static auto rect10 = GPU::SPRT::create(GPU::AreaI16({GPU::Display::Width/2, GPU::Display::Height/2 - 32}, {32, 32}).centered(), {{0, 0}, TriangleClut}, GPU::Color24::Grey()).linked(); static void load_assets() { static const CDFile Assets[] = { diff --git a/include/PSX/GPU/Primitives/primitive_rectangle_types.hpp b/include/PSX/GPU/Primitives/primitive_rectangle_types.hpp index 700ef19f..d4c0a7b0 100644 --- a/include/PSX/GPU/Primitives/primitive_rectangle_types.hpp +++ b/include/PSX/GPU/Primitives/primitive_rectangle_types.hpp @@ -44,10 +44,12 @@ namespace JabyEngine { Color24 color; Code code; - Vertex position; + Vertex position; - constexpr RECT_BASE_F() = default; - constexpr RECT_BASE_F(const Vertex& position, const Color24& color) : color(color), code(IdentityCode), position(position) { + static constexpr RECT_BASE_F create(const Vertex& position, const Color24& color) { + return RECT_BASE_F { + .color = color, .code = IdentityCode, .position = position + }; } }; @@ -62,19 +64,31 @@ namespace JabyEngine { PagePosition page; PageClut clut; - constexpr RECT_BASE_T() = default; - constexpr RECT_BASE_T(const Vertex& position, const PagePositionClut& page, const Color24& color = Color24::Grey()) : color(color), code(IdentityCode), position(position), page(page.page), clut(page.clut) { + static constexpr RECT_BASE_T create(const Vertex& position, const PagePositionClut& page, const Color24& color = Color24::Grey()) { + return RECT_BASE_T { + .color = color, .code = IdentityCode, .position = position, .page = page.page, .clut = page.clut + }; } }; template struct RECT_F : public RECT_BASE_F, public internal::RenderPrimitive>, public internal::LinkedElementCreator> { - using RECT_BASE_F::RECT_BASE_F; + static constexpr RECT_F create(const Vertex& position, const Color24& color) { + RECT_F rect; + + static_cast&>(rect) = RECT_BASE_F::create(position, color); + return rect; + } }; template struct RECT_T : public RECT_BASE_T, public internal::RenderPrimitive>, public internal::LinkedElementCreator> { - using RECT_BASE_T::RECT_BASE_T; + static constexpr RECT_T create(const Vertex& position, const PagePositionClut& page, const Color24& color = Color24::Grey()) { + RECT_T rect; + + static_cast&>(rect) = RECT_BASE_T::create(position, page, color); + return rect; + } }; } @@ -84,8 +98,12 @@ namespace JabyEngine { struct TILE : public internal::RECT_BASE_F, public internal::RenderPrimitive, public internal::LinkedElementCreator { SizeI16 size; - constexpr TILE() = default; - constexpr TILE(const AreaI16& area, const Color24& color) : RECT_BASE_F(area.position, color), size(area.size) { + static constexpr TILE create(const AreaI16& area, const Color24& color) { + TILE tile; + + static_cast(tile) = RECT_BASE_F::create(area.position, color); + tile.size = area.size; + return tile; } }; @@ -95,8 +113,12 @@ namespace JabyEngine { struct SPRT : public internal::RECT_BASE_T, public internal::RenderPrimitive, public internal::LinkedElementCreator { SizeI16 size; - constexpr SPRT() = default; - constexpr SPRT(const AreaI16& area, const PagePositionClut& page, const Color24& color = Color24::Grey()) : RECT_BASE_T(area.position, page, color), size(area.size) { + static constexpr SPRT create(const AreaI16& area, const PagePositionClut& page, const Color24& color = Color24::Grey()) { + SPRT sprt; + + static_cast(sprt) = RECT_BASE_T::create(area.position, page, color); + sprt.size = area.size; + return sprt; } }; }