Add GTrace
Make Fonts an Asset Add FormatMillis and FormatNanos
This commit is contained in:
@@ -4,18 +4,17 @@
|
||||
class Example : public Amy::App {
|
||||
public:
|
||||
Example() {
|
||||
Amy::GTrace::Scope s("Init");
|
||||
gfxInitDefault();
|
||||
romfsInit();
|
||||
consoleInit(GFX_BOTTOM, NULL);
|
||||
C3D::Init();
|
||||
Top = C3D::CreateScreen(GFX_TOP);
|
||||
Mgr = new Amy::AssetMgr();
|
||||
Mgr->AutoLoad("icon", "romfs:/icon.png");
|
||||
Iron::Init();
|
||||
Mgr->AutoLoad("icon", "romfs:/icon.png");
|
||||
Mgr->AutoLoad("font", "romfs:/ComicNeue.ttf");
|
||||
dl = new Iron::Drawlist();
|
||||
Fnt = Iron::Font::New();
|
||||
Fnt->LoadTTF("romfs:/ComicNeue.ttf");
|
||||
dl->SetFont(Fnt);
|
||||
dl->SetFont(Mgr->Get<Iron::Font>("font"));
|
||||
}
|
||||
|
||||
~Example() {
|
||||
@@ -33,15 +32,18 @@ class Example : public Amy::App {
|
||||
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",
|
||||
Amy::Utils::FormatBytes(linearSpaceFree()), Iron::VerticesDrawn(),
|
||||
Iron::IndicesDrawn());
|
||||
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()));
|
||||
C3D::StartFrame();
|
||||
Amy::GTrace::Beg("Main");
|
||||
Top->Clear();
|
||||
Top->Use();
|
||||
dl->DrawTex(Mgr->Get<Amy::Texture>("icon"));
|
||||
@@ -50,19 +52,19 @@ class Example : public Amy::App {
|
||||
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));
|
||||
dl->DrawText(Amy::fvec2(5, 50), stats, Amy::Color(255, 0, 255));
|
||||
|
||||
Iron::NewFrame();
|
||||
Iron::DrawOn(Top);
|
||||
Iron::Draw(*dl);
|
||||
dl->Clear();
|
||||
C3D::EndFrame();
|
||||
Amy::GTrace::End("Main");
|
||||
}
|
||||
|
||||
C3D::Screen* Top;
|
||||
Amy::AssetMgr* Mgr;
|
||||
Iron::Drawlist* dl;
|
||||
Iron::Font::Ref Fnt;
|
||||
};
|
||||
|
||||
int main() {
|
||||
|
||||
Reference in New Issue
Block a user