Support Gouraud Shading
This commit is contained in:
parent
60e2b7558a
commit
332ec50e6b
|
@ -39,18 +39,24 @@ static void load_assets() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
|
static constexpr auto FirstOffsetX = 64;
|
||||||
const JabyEngine::GPU::POLY_F3 triangle({{0, 0}, {64, 64}, {0, 64}}, JabyEngine::GPU::Color24(0x0, 0xFF, 0xFF));
|
const JabyEngine::GPU::POLY_F3 triangle({{0, 0}, {64, 64}, {0, 64}}, JabyEngine::GPU::Color24(0x0, 0xFF, 0xFF));
|
||||||
const JabyEngine::GPU::POLY_FT3 triangle2(
|
const JabyEngine::GPU::POLY_FT3 triangle2(
|
||||||
{{0, 0}, {64, 0}, {64, 64}}, {{0, 0}, {64, 0}, {64, 64}},
|
{{0, 0}, {64, 0}, {64, 64}}, {{0, 0}, {64, 0}, {64, 64}},
|
||||||
JabyEngine::GPU::TPage(320, 0, JabyEngine::GPU::SemiTransparency::B_Half_add_F_Half, JabyEngine::GPU::TexturePageColor::$4bit),
|
JabyEngine::GPU::TPage(320, 0, JabyEngine::GPU::SemiTransparency::B_Half_add_F_Half, JabyEngine::GPU::TexturePageColor::$4bit),
|
||||||
JabyEngine::GPU::PageClut(320, 256),
|
JabyEngine::GPU::PageClut(320, 256),
|
||||||
JabyEngine::GPU::Color24(0xFF, 0xFF, 0xFF));
|
JabyEngine::GPU::Color24(0xFF, 0xFF, 0xFF));
|
||||||
|
const JabyEngine::GPU::POLY_G3 triangle3({
|
||||||
|
{{0 + FirstOffsetX, 0}, {0xFF, 0x0, 0x0}},
|
||||||
|
{{64 + FirstOffsetX, 64}, {0x0, 0xFF, 0x0}},
|
||||||
|
{{0 + FirstOffsetX, 64}, {0x0, 0x0, 0xFF}}});
|
||||||
|
|
||||||
load_assets();
|
load_assets();
|
||||||
|
|
||||||
while(true) {
|
while(true) {
|
||||||
JabyEngine::GPU::render(triangle);
|
JabyEngine::GPU::render(triangle);
|
||||||
JabyEngine::GPU::render(triangle2);
|
JabyEngine::GPU::render(triangle2);
|
||||||
|
JabyEngine::GPU::render(triangle3);
|
||||||
|
|
||||||
JabyEngine::GPU::swap_buffers_vsync(2);
|
JabyEngine::GPU::swap_buffers_vsync(2);
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,41 +110,83 @@ namespace JabyEngine {
|
||||||
struct POLY_F3 : public internal::IsPrimitive, public internal::CodeInterface<POLY_F3> {
|
struct POLY_F3 : public internal::IsPrimitive, public internal::CodeInterface<POLY_F3> {
|
||||||
static constexpr auto IdentityCode = Code().set(Code::FlatShading).set(Code::TriVertics).set(Code::Untextured).set(Code::NonTransparent).set(Code::NoBlendTexture);
|
static constexpr auto IdentityCode = Code().set(Code::FlatShading).set(Code::TriVertics).set(Code::Untextured).set(Code::NonTransparent).set(Code::NoBlendTexture);
|
||||||
|
|
||||||
Color24 color;
|
Color24 color; // a
|
||||||
Code code = IdentityCode;
|
Code code = IdentityCode; // a
|
||||||
Vertex vertex0;
|
Vertex vertex0; // b
|
||||||
Vertex vertex1;
|
Vertex vertex1; // c
|
||||||
Vertex vertex2;
|
Vertex vertex2; // d
|
||||||
|
|
||||||
constexpr POLY_F3() = default;
|
constexpr POLY_F3() = default;
|
||||||
constexpr POLY_F3(const PositionI16 (&verticies)[3], Color24 color) : color(color), code(IdentityCode), vertex0(verticies[0]), vertex1(verticies[1]), vertex2(verticies[2]) {
|
constexpr POLY_F3(const Vertex (&verticies)[3], Color24 color) : color(color), code(IdentityCode), vertex0(verticies[0]), vertex1(verticies[1]), vertex2(verticies[2]) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct POLY_FT3 : public internal::IsPrimitive, public internal::CodeInterface<POLY_FT3> {
|
struct POLY_FT3 : public internal::IsPrimitive, public internal::CodeInterface<POLY_FT3> {
|
||||||
|
struct VertexEx {
|
||||||
|
Vertex position;
|
||||||
|
PagePosition page;
|
||||||
|
};
|
||||||
static constexpr auto IdentityCode = Code(POLY_F3::IdentityCode).set(Code::Textured);
|
static constexpr auto IdentityCode = Code(POLY_F3::IdentityCode).set(Code::Textured);
|
||||||
|
|
||||||
Color24 color;
|
Color24 color; // a
|
||||||
Code code = IdentityCode;
|
Code code = IdentityCode; // a
|
||||||
Vertex vertex0;
|
Vertex vertex0; // b
|
||||||
PagePosition page0;
|
PagePosition page0; // c
|
||||||
PageClut page_clut;
|
PageClut page_clut; // c
|
||||||
Vertex vertex1;
|
Vertex vertex1; // d
|
||||||
PagePosition page1;
|
PagePosition page1; // e
|
||||||
TPage tpage;
|
TPage tpage; // e
|
||||||
Vertex vertex2;
|
Vertex vertex2; // f
|
||||||
PagePosition page2;
|
PagePosition page2; // g
|
||||||
uint16_t padded;
|
uint16_t padded; // g
|
||||||
|
|
||||||
constexpr POLY_FT3() = default;
|
constexpr POLY_FT3() = default;
|
||||||
constexpr POLY_FT3(const PositionI16 (&verticies)[3], const PagePosition (&page_pos)[3], TPage tpage, PageClut clut, Color24 color)
|
constexpr POLY_FT3(const Vertex (&verticies)[3], const PagePosition (&page_pos)[3], TPage tpage, PageClut clut, Color24 color) :
|
||||||
: color(color), code(IdentityCode), vertex0(verticies[0]), page0(page_pos[0]), page_clut(clut),
|
color(color), code(IdentityCode),
|
||||||
vertex1(verticies[1]), page1(page_pos[1]), tpage(tpage), vertex2(verticies[2]), page2(page_pos[2]) {
|
vertex0(verticies[0]), page0(page_pos[0]), page_clut(clut),
|
||||||
}
|
vertex1(verticies[1]), page1(page_pos[1]), tpage(tpage),
|
||||||
|
vertex2(verticies[2]), page2(page_pos[2]) {}
|
||||||
|
constexpr POLY_FT3(const VertexEx (&vertices_ex)[3], TPage tpage, PageClut clut, Color24 color) :
|
||||||
|
color(color), code(IdentityCode),
|
||||||
|
vertex0(vertices_ex[0].position), page0(vertices_ex[0].page), page_clut(clut),
|
||||||
|
vertex1(vertices_ex[1].position), page1(vertices_ex[1].page), tpage(tpage),
|
||||||
|
vertex2(vertices_ex[2].position), page2(vertices_ex[2].page) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct POLY_G3 : public internal::IsPrimitive, public internal::CodeInterface<POLY_G3> {
|
||||||
|
struct VertexEx {
|
||||||
|
Vertex position;
|
||||||
|
Color24 color;
|
||||||
|
};
|
||||||
|
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
|
||||||
|
|
||||||
|
constexpr POLY_G3() = default;
|
||||||
|
constexpr POLY_G3(const Vertex (&verticies)[3], const Color24 (&color)[3]) :
|
||||||
|
color0(color[0]), code(IdentityCode), vertex0(verticies[0]),
|
||||||
|
color1(color[1]), vertex1(verticies[1]),
|
||||||
|
color2(color[2]), vertex2(verticies[2]) {}
|
||||||
|
constexpr POLY_G3(const VertexEx (&verticies_ex)[3]) :
|
||||||
|
color0(verticies_ex[0].color), code(IdentityCode), vertex0(verticies_ex[0].position),
|
||||||
|
color1(verticies_ex[1].color), vertex1(verticies_ex[1].position),
|
||||||
|
color2(verticies_ex[2].color), vertex2(verticies_ex[2].position) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef POLY_F3 FlatTriangle;
|
||||||
|
typedef POLY_FT3 FlatTexturedTriangle;
|
||||||
|
|
||||||
static_assert(sizeof(POLY_F3) == 16);
|
static_assert(sizeof(POLY_F3) == 16);
|
||||||
static_assert(sizeof(POLY_FT3) == 28);
|
static_assert(sizeof(POLY_FT3) == 28);
|
||||||
|
static_assert(sizeof(POLY_G3) == 24);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue