- Add Exit func
This commit is contained in:
@@ -4,32 +4,37 @@
|
||||
class Example : public Amy::App {
|
||||
public:
|
||||
Example() {
|
||||
Amy::Ctr::Init();
|
||||
Ctr::Init();
|
||||
consoleInit(GFX_BOTTOM, NULL);
|
||||
Amy::C3D::Init();
|
||||
Top = Amy::C3D::CreateScreen(GFX_TOP);
|
||||
C3D::Init();
|
||||
Top = C3D::CreateScreen(GFX_TOP);
|
||||
Mgr = new Amy::AssetMgr();
|
||||
Mgr->AutoLoad("icon", "romfs:/icon.png");
|
||||
Amy::Iron::Init();
|
||||
dl = new Amy::Iron::Drawlist();
|
||||
Iron::Init();
|
||||
dl = new Iron::Drawlist();
|
||||
}
|
||||
~Example() {
|
||||
delete Top;
|
||||
delete dl;
|
||||
delete Mgr;
|
||||
Amy::C3D::Deinit();
|
||||
Iron::Exit();
|
||||
C3D::Deinit();
|
||||
}
|
||||
|
||||
void Main() {
|
||||
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",
|
||||
Amy::Utils::FormatBytes(linearSpaceFree()), Amy::Iron::VerticesDrawn(),
|
||||
Amy::Iron::IndicesDrawn());
|
||||
Amy::C3D::StartFrame();
|
||||
Amy::Utils::FormatBytes(linearSpaceFree()), Iron::VerticesDrawn(),
|
||||
Iron::IndicesDrawn());
|
||||
C3D::StartFrame();
|
||||
Top->Clear();
|
||||
Top->Use();
|
||||
dl->DrawTex(Mgr->Get<Amy::Texture>("icon"));
|
||||
@@ -38,16 +43,16 @@ class Example : public Amy::App {
|
||||
dl->DrawSolid();
|
||||
dl->DrawRectFilled(0, 50, 0x4400ff00);
|
||||
|
||||
Amy::Iron::NewFrame();
|
||||
Amy::Iron::DrawOn(Top);
|
||||
Amy::Iron::Draw(*dl);
|
||||
Iron::NewFrame();
|
||||
Iron::DrawOn(Top);
|
||||
Iron::Draw(*dl);
|
||||
dl->Clear();
|
||||
Amy::C3D::EndFrame();
|
||||
C3D::EndFrame();
|
||||
}
|
||||
|
||||
Amy::C3D::Screen* Top;
|
||||
C3D::Screen* Top;
|
||||
Amy::AssetMgr* Mgr;
|
||||
Amy::Iron::Drawlist* dl;
|
||||
Iron::Drawlist* dl;
|
||||
};
|
||||
|
||||
int main() {
|
||||
|
||||
@@ -11,6 +11,7 @@ class App {
|
||||
pDelta = 0.0;
|
||||
pTime = 0.0;
|
||||
pLast = 0LL;
|
||||
pExit = false;
|
||||
}
|
||||
~App() {}
|
||||
|
||||
@@ -18,8 +19,10 @@ class App {
|
||||
void Run();
|
||||
double Delta() const { return pDelta; }
|
||||
double Time() const { return pTime; }
|
||||
void Exit() { pExit = true; }
|
||||
|
||||
private:
|
||||
bool pExit;
|
||||
ull pLast;
|
||||
double pDelta;
|
||||
double pTime;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
namespace Amy {
|
||||
void App::Run() {
|
||||
pLast = Utils::GetTimeNano();
|
||||
while (aptMainLoop()) {
|
||||
while (aptMainLoop() && !pExit) {
|
||||
ull c = Utils::GetTimeNano();
|
||||
pDelta = static_cast<double>(static_cast<double>(c) -
|
||||
static_cast<double>(pLast)) *
|
||||
|
||||
Reference in New Issue
Block a user