Files
amethyst/example/source/main.cpp

73 lines
1.9 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() {
2025-12-05 19:33:58 +01:00
gfxInitDefault();
romfsInit();
consoleInit(GFX_BOTTOM, NULL);
2025-12-01 22:39:39 +01:00
C3D::Init();
Top = C3D::CreateScreen(GFX_TOP);
Mgr = new Amy::AssetMgr();
Mgr->AutoLoad("icon", "romfs:/icon.png");
2025-12-01 22:39:39 +01:00
Iron::Init();
dl = new Iron::Drawlist();
Fnt = Iron::Font::New();
Fnt->LoadTTF("romfs:/ComicNeue.ttf");
dl->SetFont(Fnt);
}
~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::cout << std::format("\x1b[1;1HDelta: {:.3f} -> {:.3} FPS\x1b[K",
this->Delta(), 1000.0 / this->Delta());
std::cout << std::format("\x1b[2;1HTime: {:.3f}\x1b[K", this->Time());
std::cout << std::format(
"\x1b[3;1H\nLin: {}\nVertices: {}\nIndices: "
"{}\x1b[K",
2025-12-01 22:39:39 +01:00
Amy::Utils::FormatBytes(linearSpaceFree()), Iron::VerticesDrawn(),
Iron::IndicesDrawn());
C3D::StartFrame();
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), "Hello World!", 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();
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;
Iron::Font::Ref Fnt;
};
int main() {
Amy::RegisterCxxExceptionHandler();
Example App;
App.Run();
2025-11-19 22:20:27 +01:00
return 0;
}