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-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-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;
|
|
|
|
|
font.LoadTTF(ResourcePath("default.ttf"));
|
|
|
|
|
pList.SetFont(&font);
|
2026-03-21 14:43:16 +01:00
|
|
|
while (pOs->Mainloop()) {
|
|
|
|
|
pOs->ClearViewPort();
|
|
|
|
|
PD::Li::ResetPools();
|
2026-03-25 22:24:54 +01:00
|
|
|
pList.SetFontscale(pOs->SizeTranslate(PD::fvec2(0.0017)).x);
|
2026-03-21 16:39:55 +01:00
|
|
|
pList.PathRect(pOs->PositionTranslate(0.05), pOs->PositionTranslate(0.4f),
|
|
|
|
|
10.f);
|
2026-03-21 14:43:16 +01:00
|
|
|
pList.PathFill(0xff00ffff);
|
2026-03-21 15:52:09 +01:00
|
|
|
pList.BindTexture(pTex);
|
2026-03-21 16:39:55 +01:00
|
|
|
pList.DrawRectFilled(pOs->PositionTranslate(PD::fvec2(0.02f, 0.5f)),
|
|
|
|
|
pOs->SizeTranslate(PD::fvec2(0.3)), 0xffffffff);
|
2026-03-22 21:50:53 +01:00
|
|
|
pList.DrawText(5, "Hello World!", 0xff0000ff);
|
2026-03-25 20:27:23 +01:00
|
|
|
pList.DrawText(
|
|
|
|
|
pOs->PositionTranslate(PD::fvec2(0.005, 0.9)),
|
|
|
|
|
std::format("VIDC: [{}, {}, {}, {}]\nGfxDriver: {}",
|
|
|
|
|
PD::Gfx::GetNumVertices(), PD::Gfx::GetNumIndices(),
|
|
|
|
|
PD::Gfx::GetNumDrawcalls(), PD::Gfx::GetNumCommands(),
|
|
|
|
|
PD::Gfx::GetDriverName())
|
|
|
|
|
.c_str(),
|
|
|
|
|
PD::Color("#ffffff"));
|
2026-03-21 14:43:16 +01:00
|
|
|
PD::Gfx::Reset();
|
|
|
|
|
PD::Gfx::Draw(pList);
|
|
|
|
|
pList.Clear();
|
|
|
|
|
pOs->SwapBuffers();
|
|
|
|
|
}
|
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;
|
|
|
|
|
}
|