Files
amethyst/example/source/main.cpp

75 lines
2.1 KiB
C++
Raw Normal View History

2025-11-19 22:20:27 +01:00
#include <amethyst.hpp>
#include <iostream>
2025-11-19 22:20:27 +01:00
class Example : public Amy::App {
public:
Example() {
Amy::GTrace::Scope s("Init");
2025-12-05 19:33:58 +01:00
gfxInitDefault();
romfsInit();
2025-12-01 22:39:39 +01:00
C3D::Init();
Top = C3D::CreateScreen(GFX_TOP);
Mgr = new Amy::AssetMgr();
2025-12-01 22:39:39 +01:00
Iron::Init();
Mgr->AutoLoad("icon", "romfs:/icon.png");
Mgr->AutoLoad("font", "romfs:/ComicNeue.ttf");
2025-12-01 22:39:39 +01:00
dl = new Iron::Drawlist();
dl->SetFont(Mgr->Get<Iron::Font>("font"));
}
~Example() {
delete Top;
delete dl;
delete Mgr;
2025-12-01 22:39:39 +01:00
Iron::Exit();
C3D::Deinit();
2025-12-05 19:33:58 +01:00
romfsExit();
gfxExit();
}
void Main() {
2025-12-01 22:39:39 +01:00
hidScanInput();
if (hidKeysDown() & KEY_START) {
Exit();
}
std::string stats = std::format(
"Delta: {:.3} -> {:.3} FPS\nTime: {}\nLinearRam: {}\nVIT: "
"[{}/{}/{}]\nAssets: {}\nMain: {}",
this->Delta(), 1000.0 / this->Delta(),
Amy::Utils::FormatMillis(this->Time() * 1000.f),
Amy::Utils::FormatBytes(linearSpaceFree()), Amy::Iron::VerticesDrawn(),
Amy::Iron::IndicesDrawn(), Amy::Iron::IndicesDrawn() / 3,
Mgr->CountAll(),
Amy::Utils::FormatNanos(
Amy::GTrace::GetTraceRef("Main")->GetLastDiff()));
2025-12-01 22:39:39 +01:00
C3D::StartFrame();
Amy::GTrace::Beg("Main");
Top->Clear();
Top->Use();
dl->DrawTex(Mgr->Get<Amy::Texture>("icon"));
dl->DrawRectFilled(Amy::fvec2(50, 0), 48, Amy::Color(255, 255, 255, 160));
// Color only at runtime...yet (Palladium 0.6.0 dev is targeting this)
dl->DrawCircleFilled(Amy::fvec2(200, 120), 50, Amy::Color("#ffffff"), 40);
dl->DrawSolid();
dl->DrawRectFilled(0, 50, Amy::Color(0.f, 1.f, 0.f, 1.f));
dl->DrawText(Amy::fvec2(5, 50), stats, Amy::Color(255, 0, 255));
2025-12-01 22:39:39 +01:00
Iron::NewFrame();
Iron::DrawOn(Top);
Iron::Draw(*dl);
dl->Clear();
2025-12-01 22:39:39 +01:00
C3D::EndFrame();
Amy::GTrace::End("Main");
2025-11-19 22:20:27 +01:00
}
2025-12-01 22:39:39 +01:00
C3D::Screen* Top;
Amy::AssetMgr* Mgr;
2025-12-01 22:39:39 +01:00
Iron::Drawlist* dl;
};
int main() {
Amy::RegisterCxxExceptionHandler();
Example App;
App.Run();
2025-11-19 22:20:27 +01:00
return 0;
}