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