Support RectF
This commit is contained in:
@@ -11,26 +11,28 @@ enum LBA {
|
||||
__jabyengine_end_lba_request
|
||||
};
|
||||
|
||||
using namespace JabyEngine;
|
||||
|
||||
// Some default values for the objects
|
||||
static constexpr auto TriangleColor = JabyEngine::GPU::Color24(0x0, 0xFF, 0xFF);
|
||||
static constexpr auto TriangleArea = JabyEngine::GPU::AreaI16({0, 0}, {64, 64});
|
||||
static constexpr auto TriangleTPage = JabyEngine::GPU::TPage(320, 0, JabyEngine::GPU::SemiTransparency::B_Half_add_F_Half, JabyEngine::GPU::TexturePageColor::$4bit);
|
||||
static constexpr auto TriangleClut = JabyEngine::GPU::PageClut(320, 511);
|
||||
static constexpr auto TriangleColor = GPU::Color24(0x0, 0xFF, 0xFF);
|
||||
static constexpr auto TriangleArea = GPU::AreaI16({0, 0}, {64, 64});
|
||||
static constexpr auto TriangleTPage = GPU::TPage(320, 0, GPU::SemiTransparency::B_Half_add_F_Half, GPU::TexturePageColor::$4bit);
|
||||
static constexpr auto TriangleClut = GPU::PageClut(320, 511);
|
||||
|
||||
static constexpr auto RectangleColor = JabyEngine::GPU::Color24(0x80, 0x80, 0xFF);
|
||||
static constexpr auto RectangleArea = JabyEngine::GPU::AreaI16({0, TriangleArea.size.height}, {80, 80});
|
||||
static constexpr auto RectangleTPage = JabyEngine::GPU::TPage(320, 256, JabyEngine::GPU::SemiTransparency::B_Half_add_F_Half, JabyEngine::GPU::TexturePageColor::$4bit);
|
||||
static constexpr auto RectangleClut = JabyEngine::GPU::PageClut(320, 510);
|
||||
static constexpr auto RectangleColor = GPU::Color24(0x80, 0x80, 0xFF);
|
||||
static constexpr auto RectangleArea = GPU::AreaI16({0, TriangleArea.size.height}, {80, 80});
|
||||
static constexpr auto RectangleTPage = GPU::TPage(320, 256, GPU::SemiTransparency::B_Half_add_F_Half, GPU::TexturePageColor::$4bit);
|
||||
static constexpr auto RectangleClut = GPU::PageClut(320, 510);
|
||||
|
||||
static constexpr auto LineColor = JabyEngine::GPU::Color24(0xFF, 0x0, 0x0);
|
||||
static constexpr auto LineColor = GPU::Color24(0xFF, 0x0, 0x0);
|
||||
|
||||
static constexpr const auto triangle1 = JabyEngine::GPU::POLY_F3({
|
||||
static constexpr const auto triangle1 = GPU::POLY_F3({
|
||||
{TriangleArea.position.x, TriangleArea.position.y},
|
||||
{TriangleArea.size.width, TriangleArea.size.height},
|
||||
{TriangleArea.position.x, TriangleArea.size.height}},
|
||||
TriangleColor
|
||||
);
|
||||
static constexpr const auto triangle2 = JabyEngine::GPU::POLY_FT3({
|
||||
static constexpr const auto triangle2 = GPU::POLY_FT3({
|
||||
{TriangleArea.position.x, TriangleArea.position.y},
|
||||
{TriangleArea.size.width, TriangleArea.position.y},
|
||||
{TriangleArea.size.width, TriangleArea.size.height}},{
|
||||
@@ -40,96 +42,101 @@ static constexpr const auto triangle2 = JabyEngine::GPU::POLY_FT3({
|
||||
{TriangleArea.size.width, TriangleArea.size.height}},
|
||||
TriangleTPage,
|
||||
TriangleClut,
|
||||
JabyEngine::GPU::Color24::Grey()
|
||||
GPU::Color24::Grey()
|
||||
);
|
||||
static constexpr const auto triangle3 = JabyEngine::GPU::POLY_G3({
|
||||
{triangle1.vertex0.move(TriangleArea.size.width, 0), JabyEngine::GPU::Color24::Red()},
|
||||
{triangle1.vertex1.move(TriangleArea.size.width, 0), JabyEngine::GPU::Color24::Green()},
|
||||
{triangle1.vertex2.move(TriangleArea.size.width, 0), JabyEngine::GPU::Color24::Blue()}}
|
||||
static constexpr const auto triangle3 = GPU::POLY_G3({
|
||||
{triangle1.vertex0.move(TriangleArea.size.width, 0), GPU::Color24::Red()},
|
||||
{triangle1.vertex1.move(TriangleArea.size.width, 0), GPU::Color24::Green()},
|
||||
{triangle1.vertex2.move(TriangleArea.size.width, 0), GPU::Color24::Blue()}}
|
||||
);
|
||||
static constexpr const auto triangle4 = JabyEngine::GPU::POLY_GT3({
|
||||
{triangle2.vertex0.move(TriangleArea.size.width, 0), triangle2.page0, JabyEngine::GPU::Color24::Red()},
|
||||
{triangle2.vertex1.move(TriangleArea.size.width, 0), triangle2.page1, JabyEngine::GPU::Color24::Blue()},
|
||||
{triangle2.vertex2.move(TriangleArea.size.width, 0), triangle2.page2, JabyEngine::GPU::Color24::Green()}},
|
||||
static constexpr const auto triangle4 = GPU::POLY_GT3({
|
||||
{triangle2.vertex0.move(TriangleArea.size.width, 0), triangle2.page0, GPU::Color24::Red()},
|
||||
{triangle2.vertex1.move(TriangleArea.size.width, 0), triangle2.page1, GPU::Color24::Blue()},
|
||||
{triangle2.vertex2.move(TriangleArea.size.width, 0), triangle2.page2, GPU::Color24::Green()}},
|
||||
TriangleTPage,
|
||||
TriangleClut
|
||||
);
|
||||
|
||||
static constexpr const auto rectangle1 = JabyEngine::GPU::POLY_F4(RectangleArea, RectangleColor);
|
||||
static constexpr const auto rectangle2 = JabyEngine::GPU::POLY_FT4({
|
||||
static constexpr const auto rectangle1 = GPU::POLY_F4(RectangleArea, RectangleColor);
|
||||
static constexpr const auto rectangle2 = GPU::POLY_FT4({
|
||||
RectangleArea.position.move(RectangleArea.size.width, 0), RectangleArea.size}, {0, 0},
|
||||
RectangleTPage,
|
||||
RectangleClut,
|
||||
JabyEngine::GPU::Color24::Grey()
|
||||
GPU::Color24::Grey()
|
||||
);
|
||||
static constexpr const auto rectangle3 = JabyEngine::GPU::POLY_G4(
|
||||
static constexpr const auto rectangle3 = GPU::POLY_G4(
|
||||
{RectangleArea.position.move(RectangleArea.size.width*2, 0), RectangleArea.size}, {
|
||||
JabyEngine::GPU::Color24::Red(),
|
||||
JabyEngine::GPU::Color24::Blue(),
|
||||
JabyEngine::GPU::Color24::Green(),
|
||||
JabyEngine::GPU::Color24::White()});
|
||||
static constexpr const auto rectangle4 = JabyEngine::GPU::POLY_GT4(
|
||||
GPU::Color24::Red(),
|
||||
GPU::Color24::Blue(),
|
||||
GPU::Color24::Green(),
|
||||
GPU::Color24::White()});
|
||||
static constexpr const auto rectangle4 = GPU::POLY_GT4(
|
||||
{RectangleArea.position.move(RectangleArea.size.width*3, 0), RectangleArea.size}, {0, 0},
|
||||
RectangleTPage,
|
||||
RectangleClut, {
|
||||
JabyEngine::GPU::Color24::Red(),
|
||||
JabyEngine::GPU::Color24::Blue(),
|
||||
JabyEngine::GPU::Color24::Green(),
|
||||
JabyEngine::GPU::Color24::White()}
|
||||
GPU::Color24::Red(),
|
||||
GPU::Color24::Blue(),
|
||||
GPU::Color24::Green(),
|
||||
GPU::Color24::White()}
|
||||
);
|
||||
static constexpr const auto rectangle5 = JabyEngine::GPU::POLY_GT4(
|
||||
static constexpr const auto rectangle5 = GPU::POLY_GT4(
|
||||
{RectangleArea.position.move(0, RectangleArea.size.height), RectangleArea.size}, {0, 0},
|
||||
RectangleTPage,
|
||||
RectangleClut, {
|
||||
JabyEngine::GPU::Color24::Red(),
|
||||
JabyEngine::GPU::Color24::Blue(),
|
||||
JabyEngine::GPU::Color24::Green(),
|
||||
JabyEngine::GPU::Color24::White()}
|
||||
GPU::Color24::Red(),
|
||||
GPU::Color24::Blue(),
|
||||
GPU::Color24::Green(),
|
||||
GPU::Color24::White()}
|
||||
).set_semi_transparent(true);
|
||||
|
||||
static constexpr const auto line1 = JabyEngine::GPU::LINE_F::create(LineColor,
|
||||
static constexpr const auto line1 = GPU::LINE_F::create(LineColor,
|
||||
{0, 0},
|
||||
{JabyEngine::GPU::Display::Width, JabyEngine::GPU::Display::Height}
|
||||
{GPU::Display::Width, GPU::Display::Height}
|
||||
);
|
||||
static constexpr const auto line2 = JabyEngine::GPU::LINE_F::create(LineColor.invert(),
|
||||
JabyEngine::GPU::Vertex(0, 0),
|
||||
JabyEngine::GPU::Vertex(16, 0),
|
||||
JabyEngine::GPU::Vertex(16, 16),
|
||||
JabyEngine::GPU::Vertex(0, 0)
|
||||
static constexpr const auto line2 = GPU::LINE_F::create(LineColor.invert(),
|
||||
GPU::Vertex(0, 0),
|
||||
GPU::Vertex(16, 0),
|
||||
GPU::Vertex(16, 16),
|
||||
GPU::Vertex(0, 0)
|
||||
);
|
||||
static constexpr const auto line3 = JabyEngine::GPU::LINE_G::create(
|
||||
{LineColor, {JabyEngine::GPU::Display::Width, 0}},
|
||||
{LineColor.invert(), {0, JabyEngine::GPU::Display::Height}}
|
||||
static constexpr const auto line3 = GPU::LINE_G::create(
|
||||
{LineColor, {GPU::Display::Width, 0}},
|
||||
{LineColor.invert(), {0, GPU::Display::Height}}
|
||||
);
|
||||
static constexpr const auto line4 = JabyEngine::GPU::LINE_G::create(
|
||||
JabyEngine::GPU::ColorVertex{JabyEngine::GPU::Color24::Red(), {0, 0}},
|
||||
JabyEngine::GPU::ColorVertex{JabyEngine::GPU::Color24::Green(), {0, 16}},
|
||||
JabyEngine::GPU::ColorVertex{JabyEngine::GPU::Color24::Blue(), {16, 16}},
|
||||
JabyEngine::GPU::ColorVertex{JabyEngine::GPU::Color24::White(), {0, 0}}
|
||||
static constexpr const auto line4 = GPU::LINE_G::create(
|
||||
GPU::ColorVertex{GPU::Color24::Red(), {0, 0}},
|
||||
GPU::ColorVertex{GPU::Color24::Green(), {0, 16}},
|
||||
GPU::ColorVertex{GPU::Color24::Blue(), {16, 16}},
|
||||
GPU::ColorVertex{GPU::Color24::White(), {0, 0}}
|
||||
);
|
||||
|
||||
static constexpr const auto rect1 = GPU::RECT_FVAR(GPU::Color24::Green(), GPU::AreaI16({GPU::Display::Width - 32, GPU::Display::Height - 32}, {32, 32}));
|
||||
static constexpr const auto rect2 = GPU::RECT_F16(GPU::Color24::Blue(), {GPU::Display::Width - 16, GPU::Display::Height - 16});
|
||||
static constexpr const auto rect3 = GPU::RECT_F8(GPU::Color24::Yellow(), {GPU::Display::Width - 8, GPU::Display::Height - 8});
|
||||
static constexpr const auto rect4 = GPU::RECT_F1(GPU::Color24::Red(), {GPU::Display::Width - 1, GPU::Display::Height - 1});
|
||||
|
||||
static void load_assets() {
|
||||
static const JabyEngine::CDFile Assets[] = {
|
||||
JabyEngine::CDFileBuilder::simple_tim(LBA::FONT, JabyEngine::SimpleTIM(320, 0, 320, 511)),
|
||||
JabyEngine::CDFileBuilder::simple_tim(LBA::ICON, JabyEngine::SimpleTIM(320, 256, 320, 510)),
|
||||
static const CDFile Assets[] = {
|
||||
CDFileBuilder::simple_tim(LBA::FONT, SimpleTIM(320, 0, 320, 511)),
|
||||
CDFileBuilder::simple_tim(LBA::ICON, SimpleTIM(320, 256, 320, 510)),
|
||||
};
|
||||
|
||||
const auto buffer_cfg = JabyEngine::CDFileProcessor::BufferConfiguration::new_default();
|
||||
JabyEngine::CDFileProcessor file_processor;
|
||||
const auto buffer_cfg = CDFileProcessor::BufferConfiguration::new_default();
|
||||
CDFileProcessor file_processor;
|
||||
|
||||
file_processor.setup(lba, Assets, buffer_cfg);
|
||||
while(true) {
|
||||
switch(file_processor.process()) {
|
||||
case JabyEngine::Progress::InProgress:
|
||||
case Progress::InProgress:
|
||||
break;
|
||||
|
||||
case JabyEngine::Progress::Done:
|
||||
case Progress::Done:
|
||||
if(!file_processor.next(lba, buffer_cfg)) {
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
case JabyEngine::Progress::Error:
|
||||
case Progress::Error:
|
||||
printf("Error detected! Aborting load\n");
|
||||
return;
|
||||
}
|
||||
@@ -141,23 +148,28 @@ void main() {
|
||||
load_assets();
|
||||
|
||||
while(true) {
|
||||
JabyEngine::GPU::render(triangle1);
|
||||
JabyEngine::GPU::render(triangle2);
|
||||
JabyEngine::GPU::render(triangle3);
|
||||
JabyEngine::GPU::render(triangle4);
|
||||
GPU::render(triangle1);
|
||||
GPU::render(triangle2);
|
||||
GPU::render(triangle3);
|
||||
GPU::render(triangle4);
|
||||
|
||||
JabyEngine::GPU::render(rectangle1);
|
||||
JabyEngine::GPU::render(rectangle2);
|
||||
JabyEngine::GPU::render(rectangle3);
|
||||
JabyEngine::GPU::render(rectangle4);
|
||||
JabyEngine::GPU::render(rectangle5);
|
||||
GPU::render(rectangle1);
|
||||
GPU::render(rectangle2);
|
||||
GPU::render(rectangle3);
|
||||
GPU::render(rectangle4);
|
||||
GPU::render(rectangle5);
|
||||
|
||||
JabyEngine::GPU::render(line1);
|
||||
JabyEngine::GPU::render(line2);
|
||||
JabyEngine::GPU::render(line3);
|
||||
JabyEngine::GPU::render(line4);
|
||||
GPU::render(rect1);
|
||||
GPU::render(rect2);
|
||||
GPU::render(rect3);
|
||||
GPU::render(rect4);
|
||||
|
||||
JabyEngine::GPU::swap_buffers_vsync(2);
|
||||
GPU::render(line1);
|
||||
GPU::render(line2);
|
||||
GPU::render(line3);
|
||||
GPU::render(line4);
|
||||
|
||||
GPU::swap_buffers_vsync(2);
|
||||
}
|
||||
}
|
||||
__declare_lba_header(LBA);
|
Reference in New Issue
Block a user