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-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-03-26 21:02:10 +01:00
|
|
|
PD::Ultra::Layout lyt;
|
2026-03-29 04:28:45 +02:00
|
|
|
lyt.SetViewport(PD::fvec2(1280, 720));
|
2026-03-26 21:02:10 +01:00
|
|
|
lyt.SetFont(font);
|
2026-03-29 04:28:45 +02:00
|
|
|
PD::Ultra::Rect r;
|
|
|
|
|
r.SetColor(0xff0000ff);
|
|
|
|
|
r.SetRounding(10.f);
|
|
|
|
|
r.SetLined(true);
|
|
|
|
|
r.SetPosition(250, 150);
|
|
|
|
|
r.SetSize(100, 70);
|
|
|
|
|
PD::Ultra::Rect rr;
|
|
|
|
|
r.SetColor(0xff0000ff);
|
|
|
|
|
r.SetRounding(10.f);
|
|
|
|
|
r.SetPosition(250, 150);
|
|
|
|
|
r.SetSize(100, 70);
|
|
|
|
|
lyt.Push(&rr);
|
|
|
|
|
lyt.Push(&r);
|
2026-03-26 21:02:10 +01:00
|
|
|
PD::Ultra::Text txt;
|
2026-03-29 04:28:45 +02:00
|
|
|
txt.SetPosition(PD::fvec2(5, 200));
|
|
|
|
|
txt.SetText("OpenGL");
|
|
|
|
|
txt.SetColor(PD::Color("#ffffffff"));
|
|
|
|
|
lyt.Push(&txt);
|
2026-03-21 14:43:16 +01:00
|
|
|
while (pOs->Mainloop()) {
|
|
|
|
|
pOs->ClearViewPort();
|
|
|
|
|
PD::Li::ResetPools();
|
2026-03-29 04:28:45 +02:00
|
|
|
pList.DrawRectFilled(150, 50, 0x88ffffff);
|
|
|
|
|
pList.DrawRect(150, 50, 0xffffffff);
|
2026-03-26 21:02:10 +01:00
|
|
|
lyt.Render();
|
2026-03-29 04:28:45 +02:00
|
|
|
pList.DrawText(
|
|
|
|
|
5,
|
2026-03-26 21:02:10 +01:00
|
|
|
std::format(
|
|
|
|
|
"Font Scale: {}\nVP: [{}]\nVIDC: [{}, {}, {}, {}]\nGfxDriver: {}",
|
|
|
|
|
pList.GetFontScale(), pOs->GetViewport(), PD::Gfx::GetNumVertices(),
|
|
|
|
|
PD::Gfx::GetNumIndices(), PD::Gfx::GetNumDrawcalls(),
|
|
|
|
|
PD::Gfx::GetNumCommands(), PD::Gfx::GetDriverName())
|
2026-03-25 20:27:23 +01:00
|
|
|
.c_str(),
|
2026-03-29 04:28:45 +02:00
|
|
|
0xffffffff);
|
2026-03-21 14:43:16 +01:00
|
|
|
PD::Gfx::Reset();
|
|
|
|
|
PD::Gfx::Draw(pList);
|
2026-03-26 21:02:10 +01:00
|
|
|
PD::Gfx::Draw(lyt.Data());
|
2026-03-21 14:43:16 +01:00
|
|
|
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;
|
|
|
|
|
}
|