2026-03-21 14:43:16 +01:00
|
|
|
#include <os/desktopos.hpp>
|
|
|
|
|
#include <os/horizon-ctr.hpp>
|
|
|
|
|
#include <os/horizon-nx.hpp>
|
2026-03-16 17:33:46 +01:00
|
|
|
#include <palladium>
|
2026-03-17 16:47:19 +01:00
|
|
|
|
2026-03-26 21:02:10 +01:00
|
|
|
////
|
2026-03-28 13:52:36 +01:00
|
|
|
#include <pd/ultra/elems/image.hpp>
|
2026-03-26 21:02:10 +01:00
|
|
|
#include <pd/ultra/elems/rect.hpp>
|
|
|
|
|
#include <pd/ultra/elems/text.hpp>
|
|
|
|
|
#include <pd/ultra/layout.hpp>
|
|
|
|
|
////
|
|
|
|
|
|
2026-03-21 14:43:16 +01:00
|
|
|
PD::OsCtx* pOs = nullptr;
|
2026-03-17 16:47:19 +01:00
|
|
|
|
2026-03-21 14:43:16 +01:00
|
|
|
const char* ResourcePath(const char* in) {
|
|
|
|
|
#if defined(__SWITCH__) || defined(__3DS__)
|
|
|
|
|
static char rbuf[512];
|
|
|
|
|
std::snprintf(rbuf, sizeof(rbuf), "romfs:/%s", in);
|
|
|
|
|
return rbuf;
|
2026-03-18 09:31:47 +01:00
|
|
|
#else
|
2026-03-21 14:43:16 +01:00
|
|
|
return in;
|
2026-03-18 09:31:47 +01:00
|
|
|
#endif
|
2026-03-21 14:43:16 +01:00
|
|
|
}
|
2026-03-16 17:33:46 +01:00
|
|
|
|
2026-04-03 12:43:49 +02:00
|
|
|
class MainMenu : public PD::Ultra::Layout {
|
|
|
|
|
public:
|
|
|
|
|
MainMenu(PD::Li::Font& font) {
|
|
|
|
|
SetBaseViewport(PD::ivec2(1280, 720));
|
|
|
|
|
pBackground.SetSize(800, 450);
|
|
|
|
|
pBackground.SetColor(PD::Color("#ffffffff"));
|
|
|
|
|
pBackground.SetAlignment(UltraAlignment_CenterHorizontal |
|
|
|
|
|
UltraAlignment_CenterVertical);
|
|
|
|
|
Push(pBackground);
|
|
|
|
|
pText.SetColor(PD::Color("#000000"));
|
|
|
|
|
pText.SetText("Hello World");
|
|
|
|
|
pText.SetAlignment(UltraAlignment_CenterHorizontal |
|
|
|
|
|
UltraAlignment_CenterVertical);
|
|
|
|
|
pText.SetFont(font);
|
|
|
|
|
Push(pText);
|
|
|
|
|
}
|
|
|
|
|
~MainMenu() {}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
PD::Ultra::Rect pBackground;
|
|
|
|
|
PD::Ultra::Text pText;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class App {
|
|
|
|
|
public:
|
|
|
|
|
App(PD::Li::Font& font) : main(font) {}
|
|
|
|
|
~App() {}
|
|
|
|
|
|
|
|
|
|
void Update(PD::ivec2 vp, PD::Li::Drawlist& list) {
|
|
|
|
|
main.SetViewport(vp);
|
|
|
|
|
main.Render(list);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
MainMenu main;
|
|
|
|
|
};
|
|
|
|
|
|
2026-03-17 16:47:19 +01:00
|
|
|
int main(int argc, char** argv) {
|
2026-03-22 21:50:53 +01:00
|
|
|
// PD::LogFilter(PD::LogLevel::Warning);
|
2026-03-17 16:47:19 +01:00
|
|
|
Driver drv = Driver::OpenGL3;
|
|
|
|
|
if (argc == 2) {
|
|
|
|
|
if (std::string(argv[1]) == "gl2") {
|
|
|
|
|
drv = Driver::OpenGL2;
|
|
|
|
|
} else if (std::string(argv[1]) == "gl3") {
|
|
|
|
|
drv = Driver::OpenGL3;
|
|
|
|
|
} else if (std::string(argv[1]) == "dx9") {
|
|
|
|
|
drv = Driver::DirectX9;
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-03-21 14:43:16 +01:00
|
|
|
#if defined(__SWITCH__)
|
|
|
|
|
pOs = new PD::HorizonNX(drv);
|
|
|
|
|
#elif defined(__3DS__)
|
|
|
|
|
pOs = new PD::HorizonCtr(drv);
|
|
|
|
|
#else
|
|
|
|
|
pOs = new PD::DesktopOS(drv);
|
|
|
|
|
#endif
|
|
|
|
|
pOs->Init();
|
|
|
|
|
PD::Gfx::Init();
|
|
|
|
|
PD::Li::Drawlist pList;
|
2026-03-21 15:52:09 +01:00
|
|
|
PD::Image img(ResourcePath("icon.png"));
|
|
|
|
|
auto pTex = PD::Gfx::LoadTexture(img, img.Width(), img.Height());
|
2026-03-22 21:50:53 +01:00
|
|
|
PD::Li::Font font;
|
2026-03-26 21:02:10 +01:00
|
|
|
font.LoadTTF(ResourcePath("default.ttf"), 64);
|
2026-03-22 21:50:53 +01:00
|
|
|
pList.SetFont(&font);
|
2026-04-03 12:43:49 +02:00
|
|
|
App app(font);
|
2026-03-21 14:43:16 +01:00
|
|
|
while (pOs->Mainloop()) {
|
2026-04-03 14:12:42 +02:00
|
|
|
PD::Hid::Update();
|
2026-03-21 14:43:16 +01:00
|
|
|
pOs->ClearViewPort();
|
2026-04-03 12:43:49 +02:00
|
|
|
PD::Li::ResetPools(); // Move to other place (or refactor this)
|
|
|
|
|
app.Update(pOs->GetViewport(), pList);
|
2026-04-03 14:12:42 +02:00
|
|
|
pList.DrawText(5, std::format("Mouse: {}", PD::Hid::MousePos()).c_str(),
|
|
|
|
|
PD::Color("#ffffffff"));
|
2026-03-21 14:43:16 +01:00
|
|
|
PD::Gfx::Reset();
|
|
|
|
|
PD::Gfx::Draw(pList);
|
|
|
|
|
pList.Clear();
|
|
|
|
|
pOs->SwapBuffers();
|
|
|
|
|
}
|
2026-03-26 21:02:10 +01:00
|
|
|
font.Delete();
|
2026-03-21 15:52:09 +01:00
|
|
|
PD::Gfx::DeleteTexture(pTex);
|
2026-03-21 14:43:16 +01:00
|
|
|
PD::Gfx::Deinit();
|
|
|
|
|
pOs->Deinit();
|
|
|
|
|
delete pOs;
|
2026-03-16 17:33:46 +01:00
|
|
|
return 0;
|
|
|
|
|
}
|