3ds: move ui7 to bottom screne
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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); }
|
||||
|
||||
Reference in New Issue
Block a user