diff --git a/tests/gfx/include/os-ctx.hpp b/tests/gfx/include/os-ctx.hpp index e017b60..ae333ee 100644 --- a/tests/gfx/include/os-ctx.hpp +++ b/tests/gfx/include/os-ctx.hpp @@ -21,6 +21,8 @@ class OsCtx { virtual bool Mainloop() { return false; } virtual void ClearViewPort() {} virtual void SwapBuffers() {} + virtual int GetScreenCount() { return 1; } + virtual void DrawOnScreen(int s = 0) {} PD::fvec2 PositionTranslate(PD::fvec2 in) { return fvec2(in.x * pViewPort.x, in.y * pViewPort.y); } diff --git a/tests/gfx/include/os/horizon-ctr.hpp b/tests/gfx/include/os/horizon-ctr.hpp index 43e49b9..fb4e83c 100644 --- a/tests/gfx/include/os/horizon-ctr.hpp +++ b/tests/gfx/include/os/horizon-ctr.hpp @@ -13,6 +13,8 @@ class HorizonCtr : public PD::OsCtx { bool Mainloop() override; void ClearViewPort() override; void SwapBuffers() override; + int GetScreenCount() override { return 2; } + void DrawOnScreen(int s) override; private: struct Impl; diff --git a/tests/gfx/source/main.cpp b/tests/gfx/source/main.cpp index eeee77f..42602b4 100644 --- a/tests/gfx/source/main.cpp +++ b/tests/gfx/source/main.cpp @@ -208,11 +208,17 @@ int main(int argc, char** argv) { RightStick.pColor = "#00ffff"; PD::UI7::Context ui7; ui7.GetIO().Font = &font; +#ifdef __3DS__ + ui7.AddViewPort("Default", PD::ivec4(0, 0, 320, 240)); + ui7.GetIO().FontScale = 0.5f; +#else ui7.AddViewPort("Default", PD::ivec4(0, 0, 1280, 720)); +#endif ui7.UseViewPort("Default"); bool pMetricsWin = true; while (pOs->Mainloop()) { PD::TT::End("OSCTX::MainLoop"); + pOs->DrawOnScreen(0); pOs->ClearViewPort(); PD::TT::Scope __st("MainLoop"); PD::TT::Beg("MainRaw"); @@ -324,7 +330,10 @@ int main(int argc, char** argv) { PD::TT::End("UI7::Context::Update"); PD::Gfx::Reset(); PD::TT::Beg("PD::Gfx::Draw"); + pOs->DrawOnScreen(1); + pOs->ClearViewPort(); PD::Gfx::Draw(ui7.GetDrawData()); + pOs->DrawOnScreen(0); PD::Gfx::Draw(pList); PD::TT::End("PD::Gfx::Draw"); pList.Clear(); diff --git a/tests/gfx/source/os/horizon-ctr.cpp b/tests/gfx/source/os/horizon-ctr.cpp index 2ae73f9..fdbbbb6 100644 --- a/tests/gfx/source/os/horizon-ctr.cpp +++ b/tests/gfx/source/os/horizon-ctr.cpp @@ -16,6 +16,7 @@ struct HorizonCtr::Impl { C3D_RenderTarget* Top = nullptr; C3D_RenderTarget* Bottom = nullptr; uint32_t* pSocBuf = nullptr; + int CurrentScreen = 0; }; void HorizonCtr::Init() { @@ -63,13 +64,25 @@ bool HorizonCtr::Mainloop() { pViewPort = ivec2(400, 240); bool _kill = hidKeysUp() & KEY_START; C3D_FrameBegin(C3D_FRAME_SYNCDRAW); + impl->CurrentScreen = 0; return aptMainLoop() && !_kill; } void HorizonCtr::ClearViewPort() { + C3D_RenderTargetClear(impl->CurrentScreen ? impl->Bottom : impl->Top, + C3D_CLEAR_ALL, PD::Color(25, 25, 25, 25), 0); +} + +void HorizonCtr::DrawOnScreen(int s) { + impl->CurrentScreen = s; + if (s == 0) { + C3D_FrameDrawOn(impl->Top); + pViewPort = PD::ivec2(400, 240); + } else if (s == 1) { + C3D_FrameDrawOn(impl->Bottom); + pViewPort = PD::ivec2(320, 240); + } PD::Gfx::SetViewPort(pViewPort); - C3D_FrameDrawOn(impl->Top); - C3D_RenderTargetClear(impl->Top, C3D_CLEAR_ALL, PD::Color(25, 25, 25, 25), 0); } void HorizonCtr::SwapBuffers() { C3D_FrameEnd(0); }