Integrate all the progress into master #6
|
@ -2,6 +2,27 @@
|
|||
#define __JABYENGINE_TYPE_TRAITS_HPP__
|
||||
|
||||
namespace JabyEngine {
|
||||
template <class T, T v>
|
||||
struct integral_constant {
|
||||
static constexpr T value = v;
|
||||
|
||||
typedef T value_type;
|
||||
typedef integral_constant<T,v> type;
|
||||
|
||||
constexpr operator T() const {
|
||||
return v;
|
||||
}
|
||||
|
||||
constexpr T operator()() const {
|
||||
return v;
|
||||
}
|
||||
};
|
||||
|
||||
typedef integral_constant<bool, true> true_type;
|
||||
typedef integral_constant<bool, false> false_type;
|
||||
|
||||
// #############################################
|
||||
|
||||
template<bool B, class T = void>
|
||||
struct enable_if {};
|
||||
|
||||
|
@ -53,6 +74,8 @@ namespace JabyEngine {
|
|||
|
||||
template<typename T, typename... Ts>
|
||||
using variadic_force_same = enable_if<conjunction<is_same<T, Ts>...>::value>::type;
|
||||
|
||||
// #############################################
|
||||
}
|
||||
|
||||
#endif //! __JABYENGINE_TYPE_TRAITS_HPP__
|
|
@ -7,15 +7,13 @@
|
|||
namespace JabyEngine {
|
||||
namespace GPU {
|
||||
struct TexPage : public internal::LinkedElementCreator<TexPage> {
|
||||
static constexpr bool is_render_primitive = true;
|
||||
|
||||
GPU_IO::GP0_t value;
|
||||
|
||||
constexpr TexPage(const PositionU16& tex_pos, TexturePageColor tex_color, SemiTransparency transparency = SemiTransparency::B_Half_add_F_Half, bool dither = false) : value{
|
||||
GPU_IO::Command::TexPage(tex_pos, transparency, tex_color, dither, false)} {}
|
||||
};
|
||||
|
||||
namespace internal {
|
||||
__jaby_engine_declare_render_primitive(TexPage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,10 @@ namespace JabyEngine {
|
|||
static constexpr auto FlatShading = !GouraudShading;
|
||||
static constexpr auto PolyLine = Bit(27 - BitCorrection);
|
||||
static constexpr auto SingleLine = !PolyLine;
|
||||
|
||||
static constexpr LineCode create() {
|
||||
return LineCode(CmdValue);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
|
@ -54,14 +58,14 @@ namespace JabyEngine {
|
|||
};
|
||||
|
||||
template<typename Body>
|
||||
struct SingleLine : public LineCodeInterface<SingleLine<Body>>, public internal::LinkedElementCreator<SingleLine<Body>> {
|
||||
struct SingleLine : public internal::RenderPrimitive<SingleLine<Body>>, public LineCodeInterface<SingleLine<Body>>, public internal::LinkedElementCreator<SingleLine<Body>> {
|
||||
LineHead head;
|
||||
Vertex start_point;
|
||||
Body end_point;
|
||||
};
|
||||
|
||||
template<typename Body, size_t N>
|
||||
struct MultiLine : public LineCodeInterface<MultiLine<Body, N>>, public internal::LinkedElementCreator<MultiLine<Body, N>> {
|
||||
struct MultiLine : public internal::RenderPrimitive<MultiLine<Body, N>>, public LineCodeInterface<MultiLine<Body, N>>, public internal::LinkedElementCreator<MultiLine<Body, N>> {
|
||||
LineHead head;
|
||||
Vertex start_point;
|
||||
Body points[N];
|
||||
|
@ -72,7 +76,7 @@ namespace JabyEngine {
|
|||
struct LINE_F {
|
||||
typedef internal::LineCode Code;
|
||||
|
||||
static constexpr auto IdentityCode = Code().set(Code::FlatShading).set(Code::SingleLine).set(Code::NonTransparent);
|
||||
static constexpr auto IdentityCode = Code::create().set(Code::FlatShading).set(Code::SingleLine).set(Code::NonTransparent);
|
||||
|
||||
static constexpr internal::SingleLine<Vertex> create(const Color24& color, const Vertex& start_point, const Vertex& end_point) {
|
||||
using namespace internal;
|
||||
|
@ -102,18 +106,6 @@ namespace JabyEngine {
|
|||
return {.head = LineHead::create(start_point.color, IdentityCode, true), .start_point = start_point.position, .points = {rest...}, .end = Termination::create()};
|
||||
}
|
||||
};
|
||||
|
||||
namespace internal {
|
||||
template<typename T>
|
||||
struct is_render_primitive<SingleLine<T>> {
|
||||
static constexpr bool value = true;
|
||||
};
|
||||
|
||||
template<typename T, size_t N>
|
||||
struct is_render_primitive<MultiLine<T, N>> {
|
||||
static constexpr bool value = true;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,10 @@ namespace JabyEngine {
|
|||
static constexpr auto FlatShading = !GouraudShading;
|
||||
static constexpr auto QuadVertics = Bit(27 - BitCorrection);
|
||||
static constexpr auto TriVertics = !QuadVertics;
|
||||
|
||||
static constexpr PolyCode create() {
|
||||
return PolyCode(CmdValue);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
|
@ -36,14 +40,14 @@ namespace JabyEngine {
|
|||
/ \
|
||||
3 - 2
|
||||
*/
|
||||
struct POLY_F3 : public internal::PolyCodeInterface<POLY_F3>, public internal::LinkedElementCreator<POLY_F3> {
|
||||
static constexpr auto IdentityCode = Code().set(Code::FlatShading).set(Code::TriVertics).set(Code::Untextured).set(Code::NonTransparent);
|
||||
struct POLY_F3 : public internal::RenderPrimitive<POLY_F3>, public internal::PolyCodeInterface<POLY_F3>, public internal::LinkedElementCreator<POLY_F3> {
|
||||
static constexpr auto IdentityCode = Code::create().set(Code::FlatShading).set(Code::TriVertics).set(Code::Untextured).set(Code::NonTransparent);
|
||||
|
||||
Color24 color; // a
|
||||
Code code = IdentityCode; // a
|
||||
Vertex vertex0; // b
|
||||
Vertex vertex1; // c
|
||||
Vertex vertex2; // d
|
||||
Color24 color; // a
|
||||
Code code; // a
|
||||
Vertex vertex0; // b
|
||||
Vertex vertex1; // c
|
||||
Vertex vertex2; // d
|
||||
|
||||
constexpr POLY_F3() = default;
|
||||
constexpr POLY_F3(const Vertex (&verticies)[3], Color24 color) :
|
||||
|
@ -54,24 +58,24 @@ namespace JabyEngine {
|
|||
}
|
||||
};
|
||||
|
||||
struct POLY_FT3 : public internal::PolyCodeInterface<POLY_FT3>, public internal::LinkedElementCreator<POLY_FT3> {
|
||||
struct POLY_FT3 : public internal::RenderPrimitive<POLY_FT3>, public internal::PolyCodeInterface<POLY_FT3>, public internal::LinkedElementCreator<POLY_FT3> {
|
||||
struct VertexEx {
|
||||
Vertex position;
|
||||
PagePosition page;
|
||||
};
|
||||
static constexpr auto IdentityCode = Code(POLY_F3::IdentityCode).set(Code::Textured);
|
||||
|
||||
Color24 color; // a
|
||||
Code code = IdentityCode; // a
|
||||
Vertex vertex0; // b
|
||||
PagePosition page0; // c
|
||||
PageClut page_clut; // c
|
||||
Vertex vertex1; // d
|
||||
PagePosition page1; // e
|
||||
TPage tpage; // e
|
||||
Vertex vertex2; // f
|
||||
PagePosition page2; // g
|
||||
uint16_t padded2; // g
|
||||
Color24 color; // a
|
||||
Code code; // a
|
||||
Vertex vertex0; // b
|
||||
PagePosition page0; // c
|
||||
PageClut page_clut; // c
|
||||
Vertex vertex1; // d
|
||||
PagePosition page1; // e
|
||||
TPage tpage; // e
|
||||
Vertex vertex2; // f
|
||||
PagePosition page2; // g
|
||||
uint16_t padded2; // g
|
||||
|
||||
constexpr POLY_FT3() = default;
|
||||
constexpr POLY_FT3(const Vertex (&verticies)[3], const PagePosition (&page_pos)[3], TPage tpage, PageClut clut, Color24 color = Color24::Grey()) : POLY_FT3({
|
||||
|
@ -85,18 +89,18 @@ namespace JabyEngine {
|
|||
vertex2(vertices_ex[2].position), page2(vertices_ex[2].page), padded2(0) {}
|
||||
};
|
||||
|
||||
struct POLY_G3 : public internal::PolyCodeInterface<POLY_G3>, public internal::LinkedElementCreator<POLY_G3> {
|
||||
struct POLY_G3 : public internal::RenderPrimitive<POLY_G3>, public internal::PolyCodeInterface<POLY_G3>, public internal::LinkedElementCreator<POLY_G3> {
|
||||
static constexpr auto IdentityCode = Code(POLY_F3::IdentityCode).set(Code::GouraudShading);
|
||||
|
||||
Color24 color0; // a
|
||||
Code code = IdentityCode; // a
|
||||
Vertex vertex0; // b
|
||||
Color24 color1; // c
|
||||
uint8_t pad1; // c
|
||||
Vertex vertex1; // d
|
||||
Color24 color2; // e
|
||||
uint8_t pad2; // e
|
||||
Vertex vertex2; // f
|
||||
Color24 color0; // a
|
||||
Code code; // a
|
||||
Vertex vertex0; // b
|
||||
Color24 color1; // c
|
||||
uint8_t pad1; // c
|
||||
Vertex vertex1; // d
|
||||
Color24 color2; // e
|
||||
uint8_t pad2; // e
|
||||
Vertex vertex2; // f
|
||||
|
||||
constexpr POLY_G3() = default;
|
||||
constexpr POLY_G3(const Vertex (&verticies)[3], const Color24 (&color)[3]) : POLY_G3({
|
||||
|
@ -109,7 +113,7 @@ namespace JabyEngine {
|
|||
color2(verticies_ex[2].color), pad2(0), vertex2(verticies_ex[2].position) {}
|
||||
};
|
||||
|
||||
struct POLY_GT3 : public internal::PolyCodeInterface<POLY_GT3>, public internal::LinkedElementCreator<POLY_GT3> {
|
||||
struct POLY_GT3 : public internal::RenderPrimitive<POLY_GT3>, public internal::PolyCodeInterface<POLY_GT3>, public internal::LinkedElementCreator<POLY_GT3> {
|
||||
struct VertexEx {
|
||||
Vertex position;
|
||||
PagePosition page;
|
||||
|
@ -117,21 +121,21 @@ namespace JabyEngine {
|
|||
};
|
||||
static constexpr auto IdentityCode = Code(POLY_G3::IdentityCode).set(Code::Textured);
|
||||
|
||||
Color24 color0; // a
|
||||
Code code = IdentityCode; // a
|
||||
Vertex vertex0; // b
|
||||
PagePosition page0; // c
|
||||
PageClut page_clut; // c
|
||||
Color24 color1; // d
|
||||
uint8_t pad1; // d
|
||||
Vertex vertex1; // e
|
||||
PagePosition page1; // f
|
||||
TPage tpage; // f
|
||||
Color24 color2; // g
|
||||
uint8_t pad2; // g
|
||||
Vertex vertex2; // h
|
||||
PagePosition page2; // i
|
||||
uint16_t pad3; // i
|
||||
Color24 color0; // a
|
||||
Code code; // a
|
||||
Vertex vertex0; // b
|
||||
PagePosition page0; // c
|
||||
PageClut page_clut; // c
|
||||
Color24 color1; // d
|
||||
uint8_t pad1; // d
|
||||
Vertex vertex1; // e
|
||||
PagePosition page1; // f
|
||||
TPage tpage; // f
|
||||
Color24 color2; // g
|
||||
uint8_t pad2; // g
|
||||
Vertex vertex2; // h
|
||||
PagePosition page2; // i
|
||||
uint16_t pad3; // i
|
||||
|
||||
constexpr POLY_GT3() = default;
|
||||
constexpr POLY_GT3(const Vertex (&verticies)[3], const PagePosition (&page_pos)[3], const Color24 (&color)[3], TPage tpage, PageClut clut) : POLY_GT3({
|
||||
|
@ -149,15 +153,15 @@ namespace JabyEngine {
|
|||
| |
|
||||
3 - 4
|
||||
*/
|
||||
struct POLY_F4 : public internal::PolyCodeInterface<POLY_F4>, public internal::LinkedElementCreator<POLY_F4> {
|
||||
struct POLY_F4 : public internal::RenderPrimitive<POLY_F4>, public internal::PolyCodeInterface<POLY_F4>, public internal::LinkedElementCreator<POLY_F4> {
|
||||
static constexpr auto IdentityCode = Code(POLY_F3::IdentityCode).set(Code::QuadVertics);
|
||||
|
||||
Color24 color; // a
|
||||
Code code = IdentityCode; // a
|
||||
Vertex vertex0; // b
|
||||
Vertex vertex1; // c
|
||||
Vertex vertex2; // d
|
||||
Vertex vertex3; // e
|
||||
Color24 color; // a
|
||||
Code code; // a
|
||||
Vertex vertex0; // b
|
||||
Vertex vertex1; // c
|
||||
Vertex vertex2; // d
|
||||
Vertex vertex3; // e
|
||||
|
||||
constexpr POLY_F4() = default;
|
||||
constexpr POLY_F4(const Vertex (&verticies)[4], Color24 color) :
|
||||
|
@ -174,24 +178,24 @@ namespace JabyEngine {
|
|||
color) {}
|
||||
};
|
||||
|
||||
struct POLY_FT4 : public internal::PolyCodeInterface<POLY_FT4>, public internal::LinkedElementCreator<POLY_FT4> {
|
||||
struct POLY_FT4 : public internal::RenderPrimitive<POLY_FT4>, public internal::PolyCodeInterface<POLY_FT4>, public internal::LinkedElementCreator<POLY_FT4> {
|
||||
typedef POLY_FT3::VertexEx VertexEx;
|
||||
static constexpr auto IdentityCode = Code(POLY_FT3::IdentityCode).set(Code::QuadVertics);
|
||||
|
||||
Color24 color; // a
|
||||
Code code = IdentityCode; // a
|
||||
Vertex vertex0; // b
|
||||
PagePosition page0; // c
|
||||
PageClut page_clut; // c
|
||||
Vertex vertex1; // d
|
||||
PagePosition page1; // e
|
||||
TPage tpage; // e
|
||||
Vertex vertex2; // f
|
||||
PagePosition page2; // g
|
||||
uint16_t pad2; // g
|
||||
Vertex vertex3; // h
|
||||
PagePosition page3; // i
|
||||
uint16_t pad3; // i
|
||||
Color24 color; // a
|
||||
Code code; // a
|
||||
Vertex vertex0; // b
|
||||
PagePosition page0; // c
|
||||
PageClut page_clut; // c
|
||||
Vertex vertex1; // d
|
||||
PagePosition page1; // e
|
||||
TPage tpage; // e
|
||||
Vertex vertex2; // f
|
||||
PagePosition page2; // g
|
||||
uint16_t pad2; // g
|
||||
Vertex vertex3; // h
|
||||
PagePosition page3; // i
|
||||
uint16_t pad3; // i
|
||||
|
||||
constexpr POLY_FT4() = default;
|
||||
constexpr POLY_FT4(const Vertex (&verticies)[4], const PagePosition (&page_pos)[4], TPage tpage, PageClut clut, Color24 color) : POLY_FT4({
|
||||
|
@ -214,21 +218,21 @@ namespace JabyEngine {
|
|||
) {}
|
||||
};
|
||||
|
||||
struct POLY_G4 : public internal::PolyCodeInterface<POLY_G4>, public internal::LinkedElementCreator<POLY_G4> {
|
||||
struct POLY_G4 : public internal::RenderPrimitive<POLY_G4>, public internal::PolyCodeInterface<POLY_G4>, public internal::LinkedElementCreator<POLY_G4> {
|
||||
static constexpr auto IdentityCode = Code(POLY_G3::IdentityCode).set(Code::QuadVertics);
|
||||
|
||||
Color24 color0; // a
|
||||
Code code = IdentityCode; // a
|
||||
Vertex vertex0; // b
|
||||
Color24 color1; // c
|
||||
uint8_t pad1; // c
|
||||
Vertex vertex1; // d
|
||||
Color24 color2; // e
|
||||
uint8_t pad2; // e
|
||||
Vertex vertex2; // f
|
||||
Color24 color3; // g
|
||||
uint8_t pad3; // g
|
||||
Vertex vertex3; // h
|
||||
Color24 color0; // a
|
||||
Code code; // a
|
||||
Vertex vertex0; // b
|
||||
Color24 color1; // c
|
||||
uint8_t pad1; // c
|
||||
Vertex vertex1; // d
|
||||
Color24 color2; // e
|
||||
uint8_t pad2; // e
|
||||
Vertex vertex2; // f
|
||||
Color24 color3; // g
|
||||
uint8_t pad3; // g
|
||||
Vertex vertex3; // h
|
||||
|
||||
constexpr POLY_G4() = default;
|
||||
constexpr POLY_G4(const Vertex (&verticies)[4], const Color24 (&color)[4]) : POLY_G4({
|
||||
|
@ -250,30 +254,30 @@ namespace JabyEngine {
|
|||
) {}
|
||||
};
|
||||
|
||||
struct POLY_GT4 : public internal::PolyCodeInterface<POLY_GT4>, public internal::LinkedElementCreator<POLY_GT4> {
|
||||
struct POLY_GT4 : public internal::RenderPrimitive<POLY_GT4>, public internal::PolyCodeInterface<POLY_GT4>, public internal::LinkedElementCreator<POLY_GT4> {
|
||||
typedef POLY_GT3::VertexEx VertexEx;
|
||||
static constexpr auto IdentityCode = Code(POLY_GT3::IdentityCode).set(Code::QuadVertics);
|
||||
|
||||
Color24 color0; // a
|
||||
Code code = IdentityCode; // a
|
||||
Vertex vertex0; // b
|
||||
PagePosition page0; // c
|
||||
PageClut page_clut; // c
|
||||
Color24 color1; // d
|
||||
uint8_t pad1; // d
|
||||
Vertex vertex1; // e
|
||||
PagePosition page1; // f
|
||||
TPage tpage; // f
|
||||
Color24 color2; // g
|
||||
uint8_t pad2; // g
|
||||
Vertex vertex2; // h
|
||||
PagePosition page2; // i
|
||||
uint16_t pad3; // i
|
||||
Color24 color3; // j
|
||||
uint8_t pad4; // j
|
||||
Vertex vertex3; // k
|
||||
PagePosition page3; // l
|
||||
uint16_t pad5; // l
|
||||
Color24 color0; // a
|
||||
Code code; // a
|
||||
Vertex vertex0; // b
|
||||
PagePosition page0; // c
|
||||
PageClut page_clut; // c
|
||||
Color24 color1; // d
|
||||
uint8_t pad1; // d
|
||||
Vertex vertex1; // e
|
||||
PagePosition page1; // f
|
||||
TPage tpage; // f
|
||||
Color24 color2; // g
|
||||
uint8_t pad2; // g
|
||||
Vertex vertex2; // h
|
||||
PagePosition page2; // i
|
||||
uint16_t pad3; // i
|
||||
Color24 color3; // j
|
||||
uint8_t pad4; // j
|
||||
Vertex vertex3; // k
|
||||
PagePosition page3; // l
|
||||
uint16_t pad5; // l
|
||||
|
||||
constexpr POLY_GT4() = default;
|
||||
constexpr POLY_GT4(const Vertex (&verticies)[4], const PagePosition (&page_pos)[4], const Color24 (&color)[4], TPage tpage, PageClut clut) : POLY_GT4({
|
||||
|
@ -305,18 +309,6 @@ namespace JabyEngine {
|
|||
typedef POLY_G4 GouraudRectangle;
|
||||
typedef POLY_GT4 GouraudTexturedRectangle;
|
||||
|
||||
namespace internal {
|
||||
__jaby_engine_declare_render_primitive(POLY_F3);
|
||||
__jaby_engine_declare_render_primitive(POLY_FT3);
|
||||
__jaby_engine_declare_render_primitive(POLY_G3);
|
||||
__jaby_engine_declare_render_primitive(POLY_GT3);
|
||||
|
||||
__jaby_engine_declare_render_primitive(POLY_F4);
|
||||
__jaby_engine_declare_render_primitive(POLY_FT4);
|
||||
__jaby_engine_declare_render_primitive(POLY_G4);
|
||||
__jaby_engine_declare_render_primitive(POLY_GT4);
|
||||
}
|
||||
|
||||
static_assert(sizeof(POLY_F3) == 16);
|
||||
static_assert(sizeof(POLY_FT3) == 28);
|
||||
static_assert(sizeof(POLY_G3) == 24);
|
||||
|
|
|
@ -21,6 +21,10 @@ namespace JabyEngine {
|
|||
static constexpr uint8_t CmdValue = 0b011;
|
||||
|
||||
static constexpr auto Size = BitRange::from_to(27 - BitCorrection, 28 - BitCorrection);
|
||||
|
||||
static constexpr RectCode create() {
|
||||
return RectCode(CmdValue);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
|
@ -36,7 +40,7 @@ namespace JabyEngine {
|
|||
template<typename RectCode::Size Size>
|
||||
struct RECT_BASE_F : public RectCodeInterface<RECT_BASE_F<Size>> {
|
||||
typedef RECT_BASE_F<Size>::Code Code;
|
||||
static constexpr auto IdentityCode = Code().set(Code::Size.with(static_cast<uint8_t>(Size))).set(Code::Untextured).set(Code::NonTransparent);
|
||||
static constexpr auto IdentityCode = Code::create().set(Code::Size.with(static_cast<uint8_t>(Size))).set(Code::Untextured).set(Code::NonTransparent);
|
||||
|
||||
Color24 color;
|
||||
Code code = IdentityCode;
|
||||
|
@ -64,12 +68,12 @@ namespace JabyEngine {
|
|||
};
|
||||
|
||||
template<typename RectCode::Size Size>
|
||||
struct RECT_F : public RECT_BASE_F<Size>, public internal::LinkedElementCreator<RECT_F<Size>> {
|
||||
struct RECT_F : public RECT_BASE_F<Size>, public internal::RenderPrimitive<RECT_F<Size>>, public internal::LinkedElementCreator<RECT_F<Size>> {
|
||||
using RECT_BASE_F<Size>::RECT_BASE_F;
|
||||
};
|
||||
|
||||
template<typename RectCode::Size Size>
|
||||
struct RECT_T : public RECT_BASE_T<Size>, public internal::LinkedElementCreator<RECT_T<Size>> {
|
||||
struct RECT_T : public RECT_BASE_T<Size>, public internal::RenderPrimitive<RECT_T<Size>>, public internal::LinkedElementCreator<RECT_T<Size>> {
|
||||
using RECT_BASE_T<Size>::RECT_BASE_T;
|
||||
};
|
||||
}
|
||||
|
@ -77,7 +81,7 @@ namespace JabyEngine {
|
|||
typedef internal::RECT_F<internal::RectCode::Size::Pixel1x1> TILE_1;
|
||||
typedef internal::RECT_F<internal::RectCode::Size::Sprite8x8> TILE_8;
|
||||
typedef internal::RECT_F<internal::RectCode::Size::Sprite16x16> TILE_16;
|
||||
struct TILE : public internal::RECT_BASE_F<internal::RectCode::Size::Variable>, public internal::LinkedElementCreator<TILE> {
|
||||
struct TILE : public internal::RECT_BASE_F<internal::RectCode::Size::Variable>, public internal::RenderPrimitive<TILE>, public internal::LinkedElementCreator<TILE> {
|
||||
SizeI16 size;
|
||||
|
||||
constexpr TILE() = default;
|
||||
|
@ -88,25 +92,13 @@ namespace JabyEngine {
|
|||
typedef internal::RECT_T<internal::RectCode::Size::Pixel1x1> SPRT_1;
|
||||
typedef internal::RECT_T<internal::RectCode::Size::Sprite8x8> SPRT_8;
|
||||
typedef internal::RECT_T<internal::RectCode::Size::Sprite16x16> SPRT_16;
|
||||
struct SPRT : public internal::RECT_BASE_T<internal::RectCode::Size::Variable>, public internal::LinkedElementCreator<SPRT> {
|
||||
struct SPRT : public internal::RECT_BASE_T<internal::RectCode::Size::Variable>, public internal::RenderPrimitive<SPRT>, public internal::LinkedElementCreator<SPRT> {
|
||||
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) {
|
||||
}
|
||||
};
|
||||
|
||||
namespace internal {
|
||||
__jaby_engine_declare_render_primitive(TILE_1);
|
||||
__jaby_engine_declare_render_primitive(TILE_8);
|
||||
__jaby_engine_declare_render_primitive(TILE_16);
|
||||
__jaby_engine_declare_render_primitive(TILE);
|
||||
|
||||
__jaby_engine_declare_render_primitive(SPRT_1);
|
||||
__jaby_engine_declare_render_primitive(SPRT_8);
|
||||
__jaby_engine_declare_render_primitive(SPRT_16);
|
||||
__jaby_engine_declare_render_primitive(SPRT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
#ifndef __JABYENGINE_PRIMITIVE_SUPPORT_TYPES_HPP__
|
||||
#define __JABYENGINE_PRIMITIVE_SUPPORT_TYPES_HPP__
|
||||
#include "../gpu_types.hpp"
|
||||
#include "../../Auxiliary/type_traits.hpp"
|
||||
#include "../../System/IOPorts/gpu_io.hpp"
|
||||
#include "../gpu_types.hpp"
|
||||
|
||||
|
||||
namespace JabyEngine {
|
||||
namespace GPU {
|
||||
|
@ -11,7 +13,7 @@ namespace JabyEngine {
|
|||
static constexpr auto BitCorrection = 24;
|
||||
static constexpr auto CmdID = BitRange::from_to(29 - BitCorrection, 31 - BitCorrection);
|
||||
|
||||
uint8_t value = bit::value::set_normalized(0u, CmdID.with(T::CmdValue));
|
||||
uint8_t value;
|
||||
|
||||
// Common values for all the primitves
|
||||
static constexpr auto Textured = Bit(26 - BitCorrection);
|
||||
|
@ -22,6 +24,8 @@ namespace JabyEngine {
|
|||
static constexpr auto BlendTexture = !NoBlendTexture;
|
||||
|
||||
constexpr CodeBase() = default;
|
||||
constexpr CodeBase(uint8_t value) : value(bit::value::set_normalized(0u, CmdID.with(value))) {
|
||||
}
|
||||
constexpr CodeBase(const T& code) : value(code.value) {
|
||||
}
|
||||
|
||||
|
@ -53,15 +57,13 @@ namespace JabyEngine {
|
|||
};
|
||||
|
||||
template<typename T>
|
||||
struct is_render_primitive {
|
||||
static constexpr bool value = false;
|
||||
};
|
||||
struct RenderPrimitive {
|
||||
static constexpr bool is_render_primitive = true;
|
||||
|
||||
#define __jaby_engine_declare_render_primitive(type) \
|
||||
template<> \
|
||||
struct is_render_primitive<type> { \
|
||||
static constexpr bool value = true; \
|
||||
}
|
||||
void set_identitiy() {
|
||||
static_cast<T&>(*this).code = T::IdentityCode;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
struct PageClut {
|
||||
|
|
|
@ -47,12 +47,12 @@ namespace JabyEngine {
|
|||
}
|
||||
|
||||
template<typename T>
|
||||
static enable_if<internal::is_render_primitive<T>::value>::type render(const T& primitive) {
|
||||
static enable_if<T::is_render_primitive>::type render(const T& primitive) {
|
||||
internal::render(reinterpret_cast<const uint32_t*>(&primitive), sizeof(T)/sizeof(uint32_t));
|
||||
}
|
||||
|
||||
template<typename T, size_t N>
|
||||
static enable_if<internal::is_render_primitive<T>::value>::type render(const LINE_F (&primitives)[N]) {
|
||||
static enable_if<T::is_render_primitive>::type render(const LINE_F (&primitives)[N]) {
|
||||
internal::render(reinterpret_cast<const uint32_t*>(&primitives), (sizeof(T)/sizeof(uint32_t))*N);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue