Readd font support (not workign yet)

This commit is contained in:
2026-03-22 21:50:53 +01:00
parent b49c0bd3dc
commit 4777c85f9a
13 changed files with 427 additions and 19 deletions
+6 -1
View File
@@ -16,7 +16,7 @@ const char* ResourcePath(const char* in) {
}
int main(int argc, char** argv) {
PD::LogFilter(PD::LogLevel::Warning);
// PD::LogFilter(PD::LogLevel::Warning);
Driver drv = Driver::OpenGL3;
if (argc == 2) {
if (std::string(argv[1]) == "gl2") {
@@ -39,6 +39,10 @@ int main(int argc, char** argv) {
PD::Li::Drawlist pList;
PD::Image img(ResourcePath("icon.png"));
auto pTex = PD::Gfx::LoadTexture(img, img.Width(), img.Height());
PD::Li::Font font;
font.LoadTTF(ResourcePath("default.ttf"));
pList.SetFont(&font);
pList.SetFontscale(0.7f);
while (pOs->Mainloop()) {
pOs->ClearViewPort();
PD::Li::ResetPools();
@@ -48,6 +52,7 @@ int main(int argc, char** argv) {
pList.BindTexture(pTex);
pList.DrawRectFilled(pOs->PositionTranslate(PD::fvec2(0.02f, 0.5f)),
pOs->SizeTranslate(PD::fvec2(0.3)), 0xffffffff);
pList.DrawText(5, "Hello World!", 0xff0000ff);
PD::Gfx::Reset();
PD::Gfx::Draw(pList);
pList.Clear();
+14 -1
View File
@@ -15,11 +15,21 @@ namespace PD {
struct HorizonCtr::Impl {
C3D_RenderTarget* Top = nullptr;
C3D_RenderTarget* Bottom = nullptr;
uint32_t* pSocBuf = nullptr;
};
void HorizonCtr::Init() {
if (impl) return;
impl = new Impl();
impl->pSocBuf = (uint32_t*)std::aligned_alloc(0x1000, 0x100000);
if (impl->pSocBuf) {
Result ret = socInit(impl->pSocBuf, 0x100000);
if (R_FAILED(ret)) {
free(impl->pSocBuf);
impl->pSocBuf = nullptr;
}
}
link3dsStdio();
romfsInit();
gfxInitDefault();
consoleInit(GFX_BOTTOM, nullptr);
@@ -41,6 +51,7 @@ void HorizonCtr::Deinit() {
C3D_Fini();
gfxExit();
romfsExit();
socExit();
delete impl;
impl = nullptr;
}
@@ -48,7 +59,9 @@ void HorizonCtr::Deinit() {
bool HorizonCtr::Mainloop() {
pViewPort = ivec2(400, 240);
return aptMainLoop();
hidScanInput();
bool _kill = hidKeysUp() & KEY_START;
return aptMainLoop() && !_kill;
}
void HorizonCtr::ClearViewPort() {
+2
View File
@@ -16,6 +16,8 @@ struct HorizonNX::Impl {
void HorizonNX::Init() {
if (impl) return;
impl = new Impl();
socketInitializeDefault();
nxlinkStdio();
romfsInit();
glfwInit();
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);