Compare commits
5
Commits
ec49f70c0b
..
stable
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6547f64d13
|
||
|
|
2b37204763
|
||
|
|
8c2bcedc93
|
||
|
|
01d3eb771e
|
||
|
|
6de3683818
|
+1
-22
@@ -56,21 +56,9 @@ struct PD_API Mat4 {
|
||||
constexpr float* Ptr() { return m.data(); }
|
||||
constexpr const float* Ptr() const { return m.data(); }
|
||||
|
||||
constexpr float& operator()(int row, int col) {
|
||||
#ifdef __3DS__
|
||||
// 3ds is full reverse order iirc
|
||||
return m[row * 4 + (3 - col)];
|
||||
#else
|
||||
return m[col * 4 + row];
|
||||
#endif
|
||||
}
|
||||
constexpr float& operator()(int row, int col) { return m[col * 4 + row]; }
|
||||
constexpr float operator()(int row, int col) const {
|
||||
#ifdef __3DS__
|
||||
// 3ds is full reverse order iirc
|
||||
return m[row * 4 + (3 - col)];
|
||||
#else
|
||||
return m[col * 4 + row];
|
||||
#endif
|
||||
}
|
||||
|
||||
constexpr Mat4 operator*(const Mat4& v) const {
|
||||
@@ -122,21 +110,12 @@ struct PD_API Mat4 {
|
||||
constexpr static Mat4 Ortho(float l, float r, float b, float t, float n,
|
||||
float f) {
|
||||
Mat4 ret;
|
||||
#ifdef __3DS__ // Patch to rotate the Matrix correctly
|
||||
ret(0, 1) = 2.f / (t - b);
|
||||
ret(0, 3) = (b + t) / (b - t);
|
||||
ret(1, 0) = 2.f / (l - r);
|
||||
ret(1, 3) = (l + r) / (r - l);
|
||||
ret(2, 2) = 1.f / (n - f);
|
||||
ret(2, 3) = 0.5f * (n + f) / (n - f) - 0.5f;
|
||||
#else
|
||||
ret(0, 0) = 2.0f / (r - l);
|
||||
ret(0, 3) = -(r + l) / (r - l);
|
||||
ret(1, 1) = 2.0f / (t - b);
|
||||
ret(1, 3) = -(t + b) / (t - b);
|
||||
ret(2, 2) = -2.0f / (f - n);
|
||||
ret(2, 3) = -(f + n) / (f - n);
|
||||
#endif
|
||||
ret(3, 3) = 1.f;
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -56,12 +56,6 @@ class PD_API Font {
|
||||
*/
|
||||
void LoadTTF(const std::vector<u8>& data, int px_height = 32,
|
||||
LiFontFlags flags = LiFontFlags_None);
|
||||
/**
|
||||
* Function that loads a default integrated font...
|
||||
* This will only work if PD_LI_INCLUDE_FONTS was set
|
||||
* on lithium build cause otherwise the font data is not included
|
||||
*/
|
||||
void LoadDefaultFont(int id = 0, int pixel_height = 32);
|
||||
/**
|
||||
* Getter for Codepoint reference
|
||||
* @return codepoint dataholder reference
|
||||
|
||||
@@ -85,13 +85,8 @@ PD_API Mat4 Mat4::Perspective(float fov, float aspect, float n, float f) {
|
||||
Mat4 ret;
|
||||
ret(0, 0) = 1.f / (aspect * _fov);
|
||||
ret(1, 1) = 1.f / _fov;
|
||||
#ifdef __3DS__
|
||||
ret(2, 3) = f * n / (n - f);
|
||||
ret(2, 2) = -(-1.f) * n / (n - f);
|
||||
#else
|
||||
ret(2, 2) = -(f + n) / (f - n);
|
||||
ret(2, 3) = -(2.f * f * n) / (f - n);
|
||||
#endif
|
||||
ret(3, 2) = -1.f;
|
||||
ret(3, 3) = 0.0f;
|
||||
return ret;
|
||||
|
||||
@@ -195,8 +195,6 @@ PD_API void Font::LoadTTF(const std::vector<u8>& data, int px_height,
|
||||
}
|
||||
}
|
||||
|
||||
PD_API void Font::LoadDefaultFont(int id, int pixel_height) {}
|
||||
|
||||
PD_API Font::Codepoint& Font::GetCodepoint(u32 c) {
|
||||
if (c < 128) {
|
||||
// Direct Access (~11% improvement)
|
||||
|
||||
+1
-1
@@ -219,7 +219,7 @@ PD_API void Menu::DrawBaseLayout() {
|
||||
if (!(Flags & UI7MenuFlags_NoResize)) {
|
||||
DynObj* r = pIO.DynObjPool.Allocate();
|
||||
*r = UI7::DynObj([](IO* io, Li::Drawlist* l, UI7::Container* self) {
|
||||
l->SetLayer(1);
|
||||
l->SetLayer(21);
|
||||
l->PathAdd(self->FinalPos() + self->GetSize() - fvec2(0, 20));
|
||||
l->PathAdd(self->FinalPos() + self->GetSize());
|
||||
l->PathAdd(self->FinalPos() + self->GetSize() - fvec2(20, 0));
|
||||
|
||||
@@ -20,9 +20,26 @@ bool ColorTests() {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IDTests() {
|
||||
std::cout << std::format("HashID32(\"1234\") -> {:016X}",
|
||||
PD::HashID32("1234").Get())
|
||||
<< std::endl;
|
||||
std::cout << std::format("HashID32(\"1235\") -> {:016X}",
|
||||
PD::HashID32("1235").Get())
|
||||
<< std::endl;
|
||||
std::cout << std::format("HashID64(\"1234\") -> {:016X}",
|
||||
PD::HashID64("1234").Get())
|
||||
<< std::endl;
|
||||
std::cout << std::format("HashID64(\"1235\") -> {:016X}",
|
||||
PD::HashID64("1235").Get())
|
||||
<< std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
int main() {
|
||||
PD::Os::UseDriver<PD::OsDriver>();
|
||||
ColorTests();
|
||||
IDTests();
|
||||
std::cout << PD::Os::GetTime() << std::endl;
|
||||
PD::Pool<int> pool;
|
||||
pool.Init(90);
|
||||
|
||||
@@ -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");
|
||||
@@ -302,6 +308,7 @@ int main(int argc, char** argv) {
|
||||
PD::TT::Beg("BuildUI7Menus");
|
||||
if (auto m = ui7.BeginMenu("Test")) {
|
||||
m->Label("Hello World!");
|
||||
m->Image(pTex, 128.f);
|
||||
ui7.EndMenu();
|
||||
}
|
||||
if (auto m = ui7.BeginMenu("LI DBG INFO")) {
|
||||
@@ -324,7 +331,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() {
|
||||
PD::Gfx::SetViewPort(pViewPort);
|
||||
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);
|
||||
C3D_RenderTargetClear(impl->Top, C3D_CLEAR_ALL, PD::Color(25, 25, 25, 25), 0);
|
||||
pViewPort = PD::ivec2(400, 240);
|
||||
} else if (s == 1) {
|
||||
C3D_FrameDrawOn(impl->Bottom);
|
||||
pViewPort = PD::ivec2(320, 240);
|
||||
}
|
||||
PD::Gfx::SetViewPort(pViewPort);
|
||||
}
|
||||
|
||||
void HorizonCtr::SwapBuffers() { C3D_FrameEnd(0); }
|
||||
|
||||
Reference in New Issue
Block a user