Compare commits
96
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
01d3eb771e
|
||
|
|
6de3683818
|
||
|
|
ec49f70c0b
|
||
|
|
6284ff885d
|
||
|
|
91c245c1a6
|
||
|
|
c828166ce4
|
||
|
|
c7816ea170
|
||
|
|
0dbf430c0c
|
||
|
|
aec9083ebb
|
||
|
|
9e6c6fd84d
|
||
|
|
7e0f3a6bf6
|
||
|
|
1ae4d0cd46
|
||
|
|
420edd0677
|
||
|
|
e8a9055090
|
||
|
|
9e27dfb0eb
|
||
|
|
42c669de55
|
||
|
|
4488425a94
|
||
|
|
eafe5c9be5
|
||
|
|
d18e397eaf
|
||
|
|
fc5a357caa
|
||
|
|
a1cb3bf290
|
||
|
|
8c1063640c
|
||
|
|
85f50df154
|
||
|
|
32c94e0776
|
||
|
|
6b5f30b334
|
||
|
|
42cb7ce2ed
|
||
|
|
26a8c230c6
|
||
|
|
0a5a86459b
|
||
|
|
0f25a70901
|
||
|
|
6a22b26a3d
|
||
|
|
245cc0f314
|
||
|
|
cb437d41a0
|
||
|
|
322ce785b9
|
||
|
|
b29e298d55
|
||
|
|
2801b876e6
|
||
|
|
f1540f0098
|
||
|
|
54584728c3
|
||
|
|
daaf473af7
|
||
|
|
9ed3ed233d
|
||
|
|
dd97aab749
|
||
|
|
0746295013
|
||
|
|
2984354884
|
||
|
|
4d2470b0c6
|
||
|
|
cfb6a9b3dd
|
||
|
|
799e779fe6
|
||
|
|
7f708a565e
|
||
|
|
280ce524bf
|
||
|
|
b99fc39444
|
||
|
|
6dbf5a4812
|
||
|
|
ff3b241dd2
|
||
|
|
7a1751589e
|
||
|
|
8a4b3c119d
|
||
|
|
1f7d96a455
|
||
|
|
c9768010f2
|
||
|
|
679de3ae94
|
||
|
|
af7fc026df
|
||
|
|
5bc8046ebe
|
||
|
|
8215baac99
|
||
|
|
a776addf11
|
||
|
|
1cf3b6f8e6
|
||
|
|
b5321ca1a1
|
||
|
|
4498c2c0fb
|
||
|
|
818b086f08
|
||
|
|
e560496512
|
||
|
|
7b6e611f12
|
||
|
|
72deaad28d
|
||
|
|
2e652a3c24
|
||
|
|
784421fa6c
|
||
|
|
bc06a3fee8
|
||
|
|
d2ab60c824
|
||
|
|
a8fe58ef0f
|
||
|
|
eea0e9844f
|
||
|
|
4777c85f9a
|
||
|
|
b49c0bd3dc
|
||
|
|
4db5d98cb2
|
||
|
|
794e06b890
|
||
|
|
d8efcd41b1
|
||
|
|
4dab1987d1
|
||
|
|
6fab4a07a9
|
||
|
|
baad2ce15c
|
||
|
|
a86c13b9a3
|
||
|
|
3b0b103eb3
|
||
|
|
6beef97cdf
|
||
|
|
afe30a5dbd
|
||
|
|
e6cd8b7d24
|
||
|
|
66602a79e0
|
||
|
|
a28b7318d2
|
||
|
|
71563e8979
|
||
|
|
7d89ab1c47
|
||
|
|
186fce803e
|
||
|
|
66412ca8e0
|
||
|
|
e04046720b
|
||
|
|
d4c59e5b61
|
||
|
|
fe9194b907
|
||
|
|
4924d86bc0
|
||
|
|
41b612ec0a
|
@@ -29,6 +29,7 @@ class GfxCitro3D : public GfxDriverBase<GfxCitro3DConfig> {
|
|||||||
TextureFilter filter = TextureFilter::Linear) override;
|
TextureFilter filter = TextureFilter::Linear) override;
|
||||||
void DeleteTexture(const Li::Texture& tex) override;
|
void DeleteTexture(const Li::Texture& tex) override;
|
||||||
void UploadPools() override;
|
void UploadPools() override;
|
||||||
|
void ClipRect() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct Impl;
|
struct Impl;
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ class GfxDirectX9 : public GfxDriverBase<GfxDirectX9Config> {
|
|||||||
TextureFilter filter = TextureFilter::Linear) override;
|
TextureFilter filter = TextureFilter::Linear) override;
|
||||||
void DeleteTexture(const Li::Texture& tex) override;
|
void DeleteTexture(const Li::Texture& tex) override;
|
||||||
void UploadPools() override;
|
void UploadPools() override;
|
||||||
|
void ClipRect() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct Impl;
|
struct Impl;
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ class GfxOpenGL2 : public GfxDriverBase<GfxOpenGL2Config> {
|
|||||||
TextureFilter filter = TextureFilter::Linear) override;
|
TextureFilter filter = TextureFilter::Linear) override;
|
||||||
void DeleteTexture(const Li::Texture& tex) override;
|
void DeleteTexture(const Li::Texture& tex) override;
|
||||||
void UploadPools() override;
|
void UploadPools() override;
|
||||||
|
void ClipRect() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void pSetupShaderAttribs(u32 shader);
|
void pSetupShaderAttribs(u32 shader);
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ class GfxOpenGL3 : public GfxDriverBase<GfxOpenGL3Config> {
|
|||||||
TextureFilter filter = TextureFilter::Linear) override;
|
TextureFilter filter = TextureFilter::Linear) override;
|
||||||
void DeleteTexture(const Li::Texture& tex) override;
|
void DeleteTexture(const Li::Texture& tex) override;
|
||||||
void UploadPools() override;
|
void UploadPools() override;
|
||||||
|
void ClipRect() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
u32 pShader = 0;
|
u32 pShader = 0;
|
||||||
|
|||||||
@@ -141,6 +141,9 @@ void GfxCitro3D::SysInit() {
|
|||||||
PDLOG("GfxCitro3D::SysInit();");
|
PDLOG("GfxCitro3D::SysInit();");
|
||||||
impl = new Impl();
|
impl = new Impl();
|
||||||
Flags |= PDGfxBackendFlags_FlipUV_Y;
|
Flags |= PDGfxBackendFlags_FlipUV_Y;
|
||||||
|
Flags |= PDGfxBackendFlags_HasClipRect;
|
||||||
|
Flags |= PDGfxBackendFlags_ReqPow2;
|
||||||
|
Flags |= PDGfxBackendFlags_ApproxSDF;
|
||||||
impl->pShaderRaw = Pica::AssembleCode(LIShaderCTR);
|
impl->pShaderRaw = Pica::AssembleCode(LIShaderCTR);
|
||||||
impl->pCode = DVLB_ParseFile((uint32_t*)impl->pShaderRaw.data(),
|
impl->pCode = DVLB_ParseFile((uint32_t*)impl->pShaderRaw.data(),
|
||||||
impl->pShaderRaw.size());
|
impl->pShaderRaw.size());
|
||||||
@@ -264,6 +267,14 @@ void GfxCitro3D::UploadPools() {
|
|||||||
BufInfo_Init(buf);
|
BufInfo_Init(buf);
|
||||||
BufInfo_Add(buf, GetVertexBufPtr(0), sizeof(Li::Vertex), 3, 0x210);
|
BufInfo_Add(buf, GetVertexBufPtr(0), sizeof(Li::Vertex), 3, 0x210);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GfxCitro3D::ClipRect() {
|
||||||
|
// This is so cursed but it works
|
||||||
|
C3D_SetScissor(CurrentHasClip ? GPU_SCISSOR_NORMAL : GPU_SCISSOR_DISABLE,
|
||||||
|
ViewPort.y - CurrentClip.w - CurrentClip.y,
|
||||||
|
ViewPort.x - CurrentClip.z - CurrentClip.x,
|
||||||
|
ViewPort.y - CurrentClip.y, ViewPort.x - CurrentClip.x);
|
||||||
|
}
|
||||||
} // namespace PD
|
} // namespace PD
|
||||||
#else
|
#else
|
||||||
namespace PD {
|
namespace PD {
|
||||||
@@ -283,5 +294,6 @@ Li::Texture GfxCitro3D::LoadTexture(const std::vector<PD::u8>& pixels, int w,
|
|||||||
}
|
}
|
||||||
void GfxCitro3D::DeleteTexture(const Li::Texture& tex) {}
|
void GfxCitro3D::DeleteTexture(const Li::Texture& tex) {}
|
||||||
void GfxCitro3D::UploadPools() {}
|
void GfxCitro3D::UploadPools() {}
|
||||||
|
void GfxCitro3D::ClipRect() {}
|
||||||
} // namespace PD
|
} // namespace PD
|
||||||
#endif
|
#endif
|
||||||
@@ -112,6 +112,7 @@ void GfxDirectX9::SysInit() {
|
|||||||
}
|
}
|
||||||
if (psBlob) psBlob->Release();
|
if (psBlob) psBlob->Release();
|
||||||
if (errBlob) errBlob->Release();
|
if (errBlob) errBlob->Release();
|
||||||
|
Flags |= PDGfxBackendFlags_HasClipRect;
|
||||||
} else {
|
} else {
|
||||||
PDERR(
|
PDERR(
|
||||||
"GfxDirectX9::SysInit Error: pDevice is not set!\nYOu need to include "
|
"GfxDirectX9::SysInit Error: pDevice is not set!\nYOu need to include "
|
||||||
@@ -285,6 +286,21 @@ void GfxDirectX9::UploadPools() {
|
|||||||
memcpy(iptr, GetIndexBufPtr(0), GetIndexPoolSize() * sizeof(u16));
|
memcpy(iptr, GetIndexBufPtr(0), GetIndexPoolSize() * sizeof(u16));
|
||||||
impl->IBO->Unlock();
|
impl->IBO->Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GfxDirectX9::ClipRect() {
|
||||||
|
if (CurrentHasClip) {
|
||||||
|
RECT r;
|
||||||
|
r.left = CurrentClip.x;
|
||||||
|
r.top = CurrentClip.y;
|
||||||
|
r.right = CurrentClip.x + CurrentClip.z;
|
||||||
|
r.bottom = CurrentClip.y + CurrentClip.w;
|
||||||
|
|
||||||
|
impl->Device->SetScissorRect(&r);
|
||||||
|
impl->Device->SetRenderState(D3DRS_SCISSORTESTENABLE, TRUE);
|
||||||
|
} else {
|
||||||
|
impl->Device->SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE);
|
||||||
|
}
|
||||||
|
}
|
||||||
} // namespace PD
|
} // namespace PD
|
||||||
#else
|
#else
|
||||||
namespace PD {
|
namespace PD {
|
||||||
@@ -304,5 +320,6 @@ Li::Texture GfxDirectX9::LoadTexture(const std::vector<PD::u8>& pixels, int w,
|
|||||||
}
|
}
|
||||||
void GfxDirectX9::DeleteTexture(const Li::Texture& tex) {}
|
void GfxDirectX9::DeleteTexture(const Li::Texture& tex) {}
|
||||||
void GfxDirectX9::UploadPools() {}
|
void GfxDirectX9::UploadPools() {}
|
||||||
|
void GfxDirectX9::ClipRect() {}
|
||||||
} // namespace PD
|
} // namespace PD
|
||||||
#endif
|
#endif
|
||||||
@@ -73,6 +73,7 @@ void GfxOpenGL2::pSetupShaderAttribs(u32 shader) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void GfxOpenGL2::SysInit() {
|
void GfxOpenGL2::SysInit() {
|
||||||
|
Flags |= PDGfxBackendFlags_HasClipRect;
|
||||||
pShader = CreateShaderProgram(pVertCode, pFragCode);
|
pShader = CreateShaderProgram(pVertCode, pFragCode);
|
||||||
glUseProgram(pShader);
|
glUseProgram(pShader);
|
||||||
glGenBuffers(1, &VBO);
|
glGenBuffers(1, &VBO);
|
||||||
@@ -183,6 +184,16 @@ void GfxOpenGL2::UploadPools() {
|
|||||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, GetIndexPoolSize() * sizeof(u16),
|
glBufferData(GL_ELEMENT_ARRAY_BUFFER, GetIndexPoolSize() * sizeof(u16),
|
||||||
GetIndexBufPtr(0), GL_DYNAMIC_DRAW);
|
GetIndexBufPtr(0), GL_DYNAMIC_DRAW);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GfxOpenGL2::ClipRect() {
|
||||||
|
if (CurrentHasClip) {
|
||||||
|
glEnable(GL_SCISSOR_TEST);
|
||||||
|
glScissor(CurrentClip.x, ViewPort.y - (CurrentClip.y + CurrentClip.w),
|
||||||
|
CurrentClip.z, CurrentClip.w);
|
||||||
|
} else {
|
||||||
|
glDisable(GL_SCISSOR_TEST);
|
||||||
|
}
|
||||||
|
}
|
||||||
} // namespace PD
|
} // namespace PD
|
||||||
#else
|
#else
|
||||||
namespace PD {
|
namespace PD {
|
||||||
@@ -203,5 +214,6 @@ Li::Texture GfxOpenGL2::LoadTexture(const std::vector<PD::u8>& pixels, int w,
|
|||||||
void GfxOpenGL2::DeleteTexture(const Li::Texture& tex) {}
|
void GfxOpenGL2::DeleteTexture(const Li::Texture& tex) {}
|
||||||
void GfxOpenGL2::pSetupShaderAttribs(u32 shader) {}
|
void GfxOpenGL2::pSetupShaderAttribs(u32 shader) {}
|
||||||
void GfxOpenGL2::UploadPools() {}
|
void GfxOpenGL2::UploadPools() {}
|
||||||
|
void GfxOpenGL2::ClipRect() {}
|
||||||
} // namespace PD
|
} // namespace PD
|
||||||
#endif
|
#endif
|
||||||
@@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
namespace PD {
|
namespace PD {
|
||||||
void GfxOpenGL3::SysInit() {
|
void GfxOpenGL3::SysInit() {
|
||||||
|
Flags |= PDGfxBackendFlags_HasClipRect;
|
||||||
std::string vcode = SpirvHelper::SPV2GLSL(
|
std::string vcode = SpirvHelper::SPV2GLSL(
|
||||||
std::vector<unsigned int>(
|
std::vector<unsigned int>(
|
||||||
Shaders::VertexShader,
|
Shaders::VertexShader,
|
||||||
@@ -159,6 +160,16 @@ void GfxOpenGL3::UploadPools() {
|
|||||||
|
|
||||||
glBindVertexArray(0);
|
glBindVertexArray(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GfxOpenGL3::ClipRect() {
|
||||||
|
if (CurrentHasClip) {
|
||||||
|
glEnable(GL_SCISSOR_TEST);
|
||||||
|
glScissor(CurrentClip.x, ViewPort.y - (CurrentClip.y + CurrentClip.w),
|
||||||
|
CurrentClip.z, CurrentClip.w);
|
||||||
|
} else {
|
||||||
|
glDisable(GL_SCISSOR_TEST);
|
||||||
|
}
|
||||||
|
}
|
||||||
} // namespace PD
|
} // namespace PD
|
||||||
#else
|
#else
|
||||||
namespace PD {
|
namespace PD {
|
||||||
@@ -178,5 +189,6 @@ Li::Texture GfxOpenGL3::LoadTexture(const std::vector<PD::u8>& pixels, int w,
|
|||||||
}
|
}
|
||||||
void GfxOpenGL3::DeleteTexture(const Li::Texture& tex) {}
|
void GfxOpenGL3::DeleteTexture(const Li::Texture& tex) {}
|
||||||
void GfxOpenGL3::UploadPools() {}
|
void GfxOpenGL3::UploadPools() {}
|
||||||
|
void GfxOpenGL3::ClipRect() {}
|
||||||
} // namespace PD
|
} // namespace PD
|
||||||
#endif
|
#endif
|
||||||
+1
-22
@@ -56,21 +56,9 @@ struct PD_API Mat4 {
|
|||||||
constexpr float* Ptr() { return m.data(); }
|
constexpr float* Ptr() { return m.data(); }
|
||||||
constexpr const float* Ptr() const { return m.data(); }
|
constexpr const float* Ptr() const { return m.data(); }
|
||||||
|
|
||||||
constexpr float& operator()(int row, int col) {
|
constexpr float& operator()(int row, int col) { return m[col * 4 + row]; }
|
||||||
#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) const {
|
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];
|
return m[col * 4 + row];
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr Mat4 operator*(const Mat4& v) const {
|
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,
|
constexpr static Mat4 Ortho(float l, float r, float b, float t, float n,
|
||||||
float f) {
|
float f) {
|
||||||
Mat4 ret;
|
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, 0) = 2.0f / (r - l);
|
||||||
ret(0, 3) = -(r + l) / (r - l);
|
ret(0, 3) = -(r + l) / (r - l);
|
||||||
ret(1, 1) = 2.0f / (t - b);
|
ret(1, 1) = 2.0f / (t - b);
|
||||||
ret(1, 3) = -(t + b) / (t - b);
|
ret(1, 3) = -(t + b) / (t - b);
|
||||||
ret(2, 2) = -2.0f / (f - n);
|
ret(2, 2) = -2.0f / (f - n);
|
||||||
ret(2, 3) = -(f + n) / (f - n);
|
ret(2, 3) = -(f + n) / (f - n);
|
||||||
#endif
|
|
||||||
ret(3, 3) = 1.f;
|
ret(3, 3) = 1.f;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,8 +9,11 @@
|
|||||||
using PDGfxBackendFlags = PD::u32;
|
using PDGfxBackendFlags = PD::u32;
|
||||||
enum PDGfxBackendFlags_ {
|
enum PDGfxBackendFlags_ {
|
||||||
PDGfxBackendFlags_None = 0,
|
PDGfxBackendFlags_None = 0,
|
||||||
PDGfxBackendFlags_FlipUV_Y = 1 << 0, // Essential for font loading
|
PDGfxBackendFlags_FlipUV_Y = 1 << 0, // Essential for font loading
|
||||||
PDGfxBackendFlags_WindingCW = 1 << 0, // Use CW instead of CCW winding
|
PDGfxBackendFlags_WindingCW = 1 << 1, // Use CW instead of CCW winding
|
||||||
|
PDGfxBackendFlags_HasClipRect = 1 << 2, // Clip rects supported
|
||||||
|
PDGfxBackendFlags_ReqPow2 = 1 << 3, // Tex size must be pow of 2
|
||||||
|
PDGfxBackendFlags_ApproxSDF = 1 << 4, // Fake SDF for non smoothstep systems
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace PD {
|
namespace PD {
|
||||||
@@ -65,6 +68,7 @@ class PD_API GfxDriver : public DriverInterface {
|
|||||||
virtual void SysReset() {}
|
virtual void SysReset() {}
|
||||||
virtual void Submit(size_t count, size_t start) {}
|
virtual void Submit(size_t count, size_t start) {}
|
||||||
virtual void UploadPools() {} // not every driver requires it
|
virtual void UploadPools() {} // not every driver requires it
|
||||||
|
virtual void ClipRect() {}
|
||||||
void RegisterTexture(const Li::Texture& tex);
|
void RegisterTexture(const Li::Texture& tex);
|
||||||
void UnregisterTexture(const Li::Texture& tex);
|
void UnregisterTexture(const Li::Texture& tex);
|
||||||
|
|
||||||
@@ -80,6 +84,8 @@ class PD_API GfxDriver : public DriverInterface {
|
|||||||
// State Variables oder so
|
// State Variables oder so
|
||||||
TextureID CurrentTex = 0;
|
TextureID CurrentTex = 0;
|
||||||
bool CurrentTexIsSDF = false;
|
bool CurrentTexIsSDF = false;
|
||||||
|
bool CurrentHasClip = false;
|
||||||
|
fvec4 CurrentClip = 0;
|
||||||
Mat4 Projection;
|
Mat4 Projection;
|
||||||
ivec2 ViewPort;
|
ivec2 ViewPort;
|
||||||
std::unordered_map<TextureID, Li::Texture> pTextureRegestry;
|
std::unordered_map<TextureID, Li::Texture> pTextureRegestry;
|
||||||
@@ -136,7 +142,7 @@ class GfxDriverBase : public GfxDriver {
|
|||||||
for (size_t i = 0; i < commands.size(); i++) {
|
for (size_t i = 0; i < commands.size(); i++) {
|
||||||
const auto& cmd = commands[i];
|
const auto& cmd = commands[i];
|
||||||
if (cmd.VertexCount > 0) {
|
if (cmd.VertexCount > 0) {
|
||||||
std::memcpy(pVtxPool.begin() + current_vtx,
|
std::memcpy(reinterpret_cast<void*>(pVtxPool.begin() + current_vtx),
|
||||||
vpool.begin() + cmd.FirstVertex,
|
vpool.begin() + cmd.FirstVertex,
|
||||||
cmd.VertexCount * sizeof(Li::Vertex));
|
cmd.VertexCount * sizeof(Li::Vertex));
|
||||||
}
|
}
|
||||||
@@ -156,14 +162,19 @@ class GfxDriverBase : public GfxDriver {
|
|||||||
while (index < commands.size()) {
|
while (index < commands.size()) {
|
||||||
CurrentTex = commands[index].Tex;
|
CurrentTex = commands[index].Tex;
|
||||||
CurrentTexIsSDF = commands[index].SDF;
|
CurrentTexIsSDF = commands[index].SDF;
|
||||||
|
CurrentHasClip = commands[index].ClipRectUsed;
|
||||||
|
CurrentClip = commands[index].ClipRect;
|
||||||
if (!CurrentTex) {
|
if (!CurrentTex) {
|
||||||
CurrentTex = pWhite.GetID();
|
CurrentTex = pWhite.GetID();
|
||||||
}
|
}
|
||||||
size_t num_indices = 0;
|
size_t num_indices = 0;
|
||||||
|
ClipRect();
|
||||||
while (index < commands.size() &&
|
while (index < commands.size() &&
|
||||||
CurrentTexIsSDF == commands[index].SDF &&
|
CurrentTexIsSDF == commands[index].SDF &&
|
||||||
(CurrentTex == commands[index].Tex ||
|
(CurrentTex == commands[index].Tex ||
|
||||||
(CurrentTex == pWhite.GetID() && commands[index].Tex == 0))) {
|
(CurrentTex == pWhite.GetID() && commands[index].Tex == 0)) &&
|
||||||
|
CurrentClip == commands[index].ClipRect &&
|
||||||
|
CurrentHasClip == commands[index].ClipRectUsed) {
|
||||||
num_indices += commands[index].IndexCount;
|
num_indices += commands[index].IndexCount;
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,9 @@ class Command {
|
|||||||
// Todo: implement
|
// Todo: implement
|
||||||
size_t VertexCountMax = 0;
|
size_t VertexCountMax = 0;
|
||||||
size_t IndexCountMax = 0;
|
size_t IndexCountMax = 0;
|
||||||
|
// ClipRect
|
||||||
|
PD::fvec4 ClipRect;
|
||||||
|
bool ClipRectUsed = false;
|
||||||
};
|
};
|
||||||
} // namespace Li
|
} // namespace Li
|
||||||
} // namespace PD
|
} // namespace PD
|
||||||
@@ -128,13 +128,18 @@ class PD_API Drawlist {
|
|||||||
void PrimTriangle(Command& cmd, const fvec2& a, const fvec2& b,
|
void PrimTriangle(Command& cmd, const fvec2& a, const fvec2& b,
|
||||||
const fvec2& c, const PD::Color& color);
|
const fvec2& c, const PD::Color& color);
|
||||||
|
|
||||||
|
void PushClipRect(const fvec4& r) { pClipRects.push_back(r); }
|
||||||
|
void PopClipRect() {
|
||||||
|
if (!pClipRects.empty()) pClipRects.pop_back();
|
||||||
|
}
|
||||||
|
bool HasClipRect() { return !pClipRects.empty(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Texture pCurrentTexture;
|
Texture pCurrentTexture;
|
||||||
int pCurrentLayer = 0;
|
int pCurrentLayer = 0;
|
||||||
Pool<Command> pCommands;
|
Pool<Command> pCommands;
|
||||||
Pool<fvec2> pPath;
|
Pool<fvec2> pPath;
|
||||||
Pool<Vertex> pVertices;
|
std::vector<fvec4> pClipRects;
|
||||||
Pool<u16> pIndices;
|
|
||||||
Font* pFont = nullptr;
|
Font* pFont = nullptr;
|
||||||
float pFontScale = 1.f;
|
float pFontScale = 1.f;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ class PD_API Container {
|
|||||||
*/
|
*/
|
||||||
Container(const fvec4& box)
|
Container(const fvec4& box)
|
||||||
: pos(fvec2(box.x, box.y)), size(fvec2(box.z - box.x, box.w - box.y)) {}
|
: pos(fvec2(box.x, box.y)), size(fvec2(box.z - box.x, box.w - box.y)) {}
|
||||||
~Container() = default;
|
virtual ~Container() = default;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Init Function Required by every Object that uses
|
* Init Function Required by every Object that uses
|
||||||
|
|||||||
@@ -87,6 +87,8 @@ enum UI7LytAdd_ {
|
|||||||
UI7LytAdd_NoCursorUpdate = 1 << 0, ///< Add without cursor alignment
|
UI7LytAdd_NoCursorUpdate = 1 << 0, ///< Add without cursor alignment
|
||||||
UI7LytAdd_NoScrollHandle = 1 << 1, ///< Skip HandleScrolling
|
UI7LytAdd_NoScrollHandle = 1 << 1, ///< Skip HandleScrolling
|
||||||
UI7LytAdd_Front = 1 << 2, ///< Add in front of the list
|
UI7LytAdd_Front = 1 << 2, ///< Add in front of the list
|
||||||
|
UI7LytAdd_NoGlobalClipping = 1 << 3, ///< Dont use global Layout clip rect
|
||||||
|
UI7LytAdd_NoClipTitlebar = 1 << 4, ///< Dont clip content behind the titlebar
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -85,13 +85,8 @@ PD_API Mat4 Mat4::Perspective(float fov, float aspect, float n, float f) {
|
|||||||
Mat4 ret;
|
Mat4 ret;
|
||||||
ret(0, 0) = 1.f / (aspect * _fov);
|
ret(0, 0) = 1.f / (aspect * _fov);
|
||||||
ret(1, 1) = 1.f / _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, 2) = -(f + n) / (f - n);
|
||||||
ret(2, 3) = -(2.f * f * n) / (f - n);
|
ret(2, 3) = -(2.f * f * n) / (f - n);
|
||||||
#endif
|
|
||||||
ret(3, 2) = -1.f;
|
ret(3, 2) = -1.f;
|
||||||
ret(3, 3) = 0.0f;
|
ret(3, 3) = 0.0f;
|
||||||
return ret;
|
return ret;
|
||||||
|
|||||||
@@ -56,6 +56,8 @@ void Command::Reset() {
|
|||||||
VertexCount = 0;
|
VertexCount = 0;
|
||||||
VertexCountMax = 0;
|
VertexCountMax = 0;
|
||||||
IndexCountMax = 0;
|
IndexCountMax = 0;
|
||||||
|
ClipRect = 0.f;
|
||||||
|
ClipRectUsed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Command& Command::Add(const Vertex& vtx) {
|
Command& Command::Add(const Vertex& vtx) {
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ PD_API void Drawlist::Clear() {
|
|||||||
pPath.ResetFast();
|
pPath.ResetFast();
|
||||||
pCommands.NoReset();
|
pCommands.NoReset();
|
||||||
pCurrentLayer = 0;
|
pCurrentLayer = 0;
|
||||||
|
pClipRects.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Command Allocation */
|
/** Command Allocation */
|
||||||
@@ -51,6 +52,10 @@ PD_API Command& Drawlist::NewCommand() {
|
|||||||
cmd->Reset();
|
cmd->Reset();
|
||||||
cmd->Layer = pCurrentLayer;
|
cmd->Layer = pCurrentLayer;
|
||||||
cmd->Tex = pCurrentTexture.GetID();
|
cmd->Tex = pCurrentTexture.GetID();
|
||||||
|
if (HasClipRect()) {
|
||||||
|
cmd->ClipRectUsed = HasClipRect();
|
||||||
|
cmd->ClipRect = pClipRects.back();
|
||||||
|
}
|
||||||
return *cmd;
|
return *cmd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,13 +44,13 @@ PD_API void Container::HandleInternalInput() {
|
|||||||
/** Internal function */
|
/** Internal function */
|
||||||
PD_API void Container::PreDraw() {
|
PD_API void Container::PreDraw() {
|
||||||
if (pCLipRectUsed) {
|
if (pCLipRectUsed) {
|
||||||
// list->PushClipRect(pClipRect);
|
list->PushClipRect(pClipRect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/** Internal function */
|
/** Internal function */
|
||||||
PD_API void Container::PostDraw() {
|
PD_API void Container::PostDraw() {
|
||||||
if (pCLipRectUsed) {
|
if (pCLipRectUsed) {
|
||||||
// list->PopClipRect();
|
list->PopClipRect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // namespace UI7
|
} // namespace UI7
|
||||||
|
|||||||
+1
-1
@@ -28,7 +28,7 @@ SOFTWARE.
|
|||||||
|
|
||||||
namespace PD {
|
namespace PD {
|
||||||
|
|
||||||
PD_API UI7::IO::IO() : DeltaStats(60), CurrentViewPort("", 0) {
|
PD_API UI7::IO::IO() : CurrentViewPort("", 0), DeltaStats(60) {
|
||||||
/** Probably not the best solution i guess */
|
/** Probably not the best solution i guess */
|
||||||
// CurrentViewPort =
|
// CurrentViewPort =
|
||||||
// ViewPort::New("Default", ivec4(ivec2(0, 0), pCtx.Gfx()->ViewPort));
|
// ViewPort::New("Default", ivec4(ivec2(0, 0), pCtx.Gfx()->ViewPort));
|
||||||
|
|||||||
+14
-4
@@ -77,6 +77,10 @@ PD_API void Layout::AddObject(Container* obj) {
|
|||||||
obj->Update();
|
obj->Update();
|
||||||
CursorMove(obj->GetSize());
|
CursorMove(obj->GetSize());
|
||||||
obj->HandleScrolling(ScrollOffset, WorkRect);
|
obj->HandleScrolling(ScrollOffset, WorkRect);
|
||||||
|
if (Flags & UI7LayoutFlags_UseClipRect) {
|
||||||
|
obj->SetClipRect(
|
||||||
|
fvec4(Pos.x, Pos.y + WorkRect.y, Size.x, Size.y - WorkRect.y));
|
||||||
|
}
|
||||||
Objects.push_back(obj);
|
Objects.push_back(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,6 +97,15 @@ PD_API void Layout::AddObjectEx(Container* obj, u32 flags) {
|
|||||||
if (!(flags & UI7LytAdd_NoScrollHandle)) {
|
if (!(flags & UI7LytAdd_NoScrollHandle)) {
|
||||||
obj->HandleScrolling(ScrollOffset, WorkRect);
|
obj->HandleScrolling(ScrollOffset, WorkRect);
|
||||||
}
|
}
|
||||||
|
if (Flags & UI7LayoutFlags_UseClipRect &&
|
||||||
|
!(flags & UI7LytAdd_NoGlobalClipping)) {
|
||||||
|
if (flags & UI7LytAdd_NoClipTitlebar) {
|
||||||
|
obj->SetClipRect(fvec4(Pos.x, Pos.y, Size.x, Size.y));
|
||||||
|
} else {
|
||||||
|
obj->SetClipRect(
|
||||||
|
fvec4(Pos.x, Pos.y + WorkRect.y, Size.x, Size.y - WorkRect.y));
|
||||||
|
}
|
||||||
|
}
|
||||||
if (flags & UI7LytAdd_Front) {
|
if (flags & UI7LytAdd_Front) {
|
||||||
Objects.push_front(obj);
|
Objects.push_front(obj);
|
||||||
} else {
|
} else {
|
||||||
@@ -171,9 +184,6 @@ PD_API void Layout::Update() {
|
|||||||
it->SetPos(it->GetPos() + Pos);
|
it->SetPos(it->GetPos() + Pos);
|
||||||
it->HandleInput();
|
it->HandleInput();
|
||||||
it->UnlockInput();
|
it->UnlockInput();
|
||||||
if (Flags & UI7LayoutFlags_UseClipRect) {
|
|
||||||
it->SetClipRect(fvec4(Pos, Size));
|
|
||||||
}
|
|
||||||
it->PreDraw();
|
it->PreDraw();
|
||||||
it->Draw();
|
it->Draw();
|
||||||
it->PostDraw();
|
it->PostDraw();
|
||||||
@@ -201,7 +211,7 @@ PD_API void Layout::Label(const std::string& label) {
|
|||||||
// Layout API
|
// Layout API
|
||||||
auto r = IO.LabelPool.Allocate();
|
auto r = IO.LabelPool.Allocate();
|
||||||
*r = UI7::Label(label, IO);
|
*r = UI7::Label(label, IO);
|
||||||
r->SetClipRect(fvec4(GetPosition(), GetPosition() + GetSize()));
|
// r->SetClipRect(fvec4(GetPosition(), GetSize()));
|
||||||
AddObject(r);
|
AddObject(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Regular → Executable
+9
-5
@@ -27,7 +27,7 @@ SOFTWARE.
|
|||||||
|
|
||||||
namespace PD {
|
namespace PD {
|
||||||
namespace UI7 {
|
namespace UI7 {
|
||||||
Menu::Menu(const ID& id, IO& io) : pIO(io), pID(id), pLayout(id, io) {
|
Menu::Menu(const ID& id, IO& io) : pLayout(id, io), pIO(io), pID(id) {
|
||||||
TitleBarHeight = pIO.FontScale * pIO.Font->PixelHeight + pIO.MenuPadding.y;
|
TitleBarHeight = pIO.FontScale * pIO.Font->PixelHeight + pIO.MenuPadding.y;
|
||||||
pLayout.WorkRect.y += TitleBarHeight;
|
pLayout.WorkRect.y += TitleBarHeight;
|
||||||
pLayout.Flags |= UI7LayoutFlags_UseClipRect;
|
pLayout.Flags |= UI7LayoutFlags_UseClipRect;
|
||||||
@@ -248,7 +248,7 @@ PD_API void Menu::DrawBaseLayout() {
|
|||||||
fvec2(pLayout.GetSize().x, pLayout.GetSize().y - TitleBarHeight));
|
fvec2(pLayout.GetSize().x, pLayout.GetSize().y - TitleBarHeight));
|
||||||
r->SetPos(fvec2(0, TitleBarHeight));
|
r->SetPos(fvec2(0, TitleBarHeight));
|
||||||
pLayout.AddObjectEx(r, UI7LytAdd_NoCursorUpdate | UI7LytAdd_NoScrollHandle |
|
pLayout.AddObjectEx(r, UI7LytAdd_NoCursorUpdate | UI7LytAdd_NoScrollHandle |
|
||||||
UI7LytAdd_Front);
|
UI7LytAdd_Front | UI7LytAdd_NoClipTitlebar);
|
||||||
}
|
}
|
||||||
if (!(Flags & UI7MenuFlags_NoTitlebar)) {
|
if (!(Flags & UI7MenuFlags_NoTitlebar)) {
|
||||||
DynObj* r = pIO.DynObjPool.Allocate();
|
DynObj* r = pIO.DynObjPool.Allocate();
|
||||||
@@ -273,7 +273,8 @@ PD_API void Menu::DrawBaseLayout() {
|
|||||||
});
|
});
|
||||||
r->SetSize(fvec2(pLayout.GetSize().x, TitleBarHeight));
|
r->SetSize(fvec2(pLayout.GetSize().x, TitleBarHeight));
|
||||||
r->SetPos(0);
|
r->SetPos(0);
|
||||||
pLayout.AddObjectEx(r, UI7LytAdd_NoCursorUpdate | UI7LytAdd_NoScrollHandle);
|
pLayout.AddObjectEx(r, UI7LytAdd_NoCursorUpdate | UI7LytAdd_NoScrollHandle |
|
||||||
|
UI7LytAdd_NoClipTitlebar);
|
||||||
|
|
||||||
/** Collapse Sym */
|
/** Collapse Sym */
|
||||||
if (!(Flags & UI7MenuFlags_NoCollapse)) {
|
if (!(Flags & UI7MenuFlags_NoCollapse)) {
|
||||||
@@ -296,8 +297,9 @@ PD_API void Menu::DrawBaseLayout() {
|
|||||||
});
|
});
|
||||||
r->SetSize(TitleBarHeight - pIO.FramePadding.y * 2);
|
r->SetSize(TitleBarHeight - pIO.FramePadding.y * 2);
|
||||||
r->SetPos(pIO.FramePadding);
|
r->SetPos(pIO.FramePadding);
|
||||||
pLayout.AddObjectEx(r,
|
pLayout.AddObjectEx(r, UI7LytAdd_NoCursorUpdate |
|
||||||
UI7LytAdd_NoCursorUpdate | UI7LytAdd_NoScrollHandle);
|
UI7LytAdd_NoScrollHandle |
|
||||||
|
UI7LytAdd_NoClipTitlebar);
|
||||||
}
|
}
|
||||||
/** Close Sym (only shown if pIsShown is not nullptr) */
|
/** Close Sym (only shown if pIsShown is not nullptr) */
|
||||||
if (!(Flags & UI7MenuFlags_NoClose) && pIsShown) {
|
if (!(Flags & UI7MenuFlags_NoClose) && pIsShown) {
|
||||||
@@ -310,11 +312,13 @@ PD_API void Menu::DrawBaseLayout() {
|
|||||||
fvec2 cpos =
|
fvec2 cpos =
|
||||||
fvec2(pLayout.Pos.x + pLayout.Size.x - size.x - pIO.FramePadding.x,
|
fvec2(pLayout.Pos.x + pLayout.Size.x - size.x - pIO.FramePadding.x,
|
||||||
pLayout.Pos.y + pIO.FramePadding.y);
|
pLayout.Pos.y + pIO.FramePadding.y);
|
||||||
|
pLayout.DrawList.SetLayer(21);
|
||||||
pLayout.DrawList.DrawLine(cpos, cpos + size,
|
pLayout.DrawList.DrawLine(cpos, cpos + size,
|
||||||
pIO.Theme.Get(UI7Color_FrameBackground), 2);
|
pIO.Theme.Get(UI7Color_FrameBackground), 2);
|
||||||
pLayout.DrawList.DrawLine(cpos + fvec2(0, size.y),
|
pLayout.DrawList.DrawLine(cpos + fvec2(0, size.y),
|
||||||
cpos + fvec2(size.x, 0),
|
cpos + fvec2(size.x, 0),
|
||||||
pIO.Theme.Get(UI7Color_FrameBackground), 2);
|
pIO.Theme.Get(UI7Color_FrameBackground), 2);
|
||||||
|
pLayout.DrawList.SetLayer(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+12
-2
@@ -158,7 +158,7 @@ PD_API void Context::AboutMenu(bool* show) {
|
|||||||
if (auto m = BeginMenu("About UI7", UI7MenuFlags_Scrolling, show)) {
|
if (auto m = BeginMenu("About UI7", UI7MenuFlags_Scrolling, show)) {
|
||||||
m->Label("Palladium UI7 " + GetVersion());
|
m->Label("Palladium UI7 " + GetVersion());
|
||||||
m->Separator();
|
m->Separator();
|
||||||
m->Label("(c) 2023-2025 René Amthor");
|
m->Label("(c) 2023-2026 René Amthor");
|
||||||
m->Label("UI7 is licensed under the MIT License.");
|
m->Label("UI7 is licensed under the MIT License.");
|
||||||
m->Label("See LICENSE for more information.");
|
m->Label("See LICENSE for more information.");
|
||||||
static bool show_build;
|
static bool show_build;
|
||||||
@@ -207,7 +207,17 @@ PD_API void Context::MetricsMenu(bool* show) {
|
|||||||
}
|
}
|
||||||
m->SeparatorText("Palladium Info");
|
m->SeparatorText("Palladium Info");
|
||||||
m->Label("Os Driver: {}", PD::Os::GetDriverName());
|
m->Label("Os Driver: {}", PD::Os::GetDriverName());
|
||||||
m->Label("Renderer: {}", PD::Gfx::GetDriverName());
|
if (m->BeginTreeNode(
|
||||||
|
std::format("Gfx Driver: {}", PD::Gfx::GetDriverName()))) {
|
||||||
|
m->SeparatorText("Features");
|
||||||
|
if (PD::Gfx::GetFlags() & PDGfxBackendFlags_HasClipRect)
|
||||||
|
m->Label("ClipRects");
|
||||||
|
if (PD::Gfx::GetFlags() & PDGfxBackendFlags_ReqPow2)
|
||||||
|
m->Label("Texture As Pow of 2");
|
||||||
|
if (PD::Gfx::GetFlags() & PDGfxBackendFlags_ApproxSDF)
|
||||||
|
m->Label("SDF Approximation");
|
||||||
|
m->EndTreeNode();
|
||||||
|
}
|
||||||
if (m->BeginTreeNode(
|
if (m->BeginTreeNode(
|
||||||
std::string(std::string("Input: ") + PD::Hid::GetDriverName()))) {
|
std::string(std::string("Input: ") + PD::Hid::GetDriverName()))) {
|
||||||
/* if (pIO.pCtx.Hid()->Flags & PD::HidDriver::Flags_HasKeyboard) {
|
/* if (pIO.pCtx.Hid()->Flags & PD::HidDriver::Flags_HasKeyboard) {
|
||||||
|
|||||||
Executable
+55
@@ -0,0 +1,55 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.22)
|
||||||
|
|
||||||
|
project(test)
|
||||||
|
|
||||||
|
set(CMAKE_CXX_STANDARD 20)
|
||||||
|
set(CMAKE_CXX_STANDARD_REQUIRED true)
|
||||||
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
|
||||||
|
set(CMAKE_EXPORT_COMPILE_COMMANDS true)
|
||||||
|
|
||||||
|
if(${CMAKE_SYSTEM_NAME} STREQUAL "Nintendo3DS")
|
||||||
|
if(${PD_BUILD_SHARED})
|
||||||
|
message(ERROR "3DS Only supports Static libraries")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
add_subdirectory(../ palladium)
|
||||||
|
|
||||||
|
if(${CMAKE_SYSTEM_NAME} STREQUAL "Nintendo3DS")
|
||||||
|
add_subdirectory(../backends/3ds pd-3ds)
|
||||||
|
else()
|
||||||
|
add_subdirectory(../backends/desktop pd-desktop)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
add_executable(test source/main.cpp
|
||||||
|
${BKND_SRC})
|
||||||
|
|
||||||
|
if(${CMAKE_SYSTEM_NAME} STREQUAL "Nintendo3DS")
|
||||||
|
target_link_libraries(test PUBLIC pd-3ds palladium)
|
||||||
|
else()
|
||||||
|
target_link_libraries(test PUBLIC pd-desktop palladium)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(${CMAKE_SYSTEM_NAME} STREQUAL "Nintendo3DS")
|
||||||
|
target_compile_options(palladium PRIVATE
|
||||||
|
$<$<COMPILE_LANGUAGE:C>:-Wall>
|
||||||
|
$<$<COMPILE_LANGUAGE:C>:-Wno-psabi>
|
||||||
|
$<$<COMPILE_LANGUAGE:CXX>:-fno-exceptions>
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(CMAKE_BUILD_TYPE STREQUAL "Release")
|
||||||
|
target_compile_options(palladium PRIVATE
|
||||||
|
$<$<CONFIG:Debug>:-O0 -g>
|
||||||
|
$<$<CONFIG:Release>:-O3>
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# set(RC_FILES
|
||||||
|
# testassets/ComicNeue.ttf
|
||||||
|
# testassets/logo.png
|
||||||
|
# testassets/test.png)
|
||||||
|
# install(FILES ${RC_FILES} DESTINATION ".")
|
||||||
|
# else()
|
||||||
|
# target_link_libraries(test PUBLIC pd-backend-3ds ctru citro3d)
|
||||||
|
# endif()
|
||||||
@@ -21,6 +21,8 @@ class OsCtx {
|
|||||||
virtual bool Mainloop() { return false; }
|
virtual bool Mainloop() { return false; }
|
||||||
virtual void ClearViewPort() {}
|
virtual void ClearViewPort() {}
|
||||||
virtual void SwapBuffers() {}
|
virtual void SwapBuffers() {}
|
||||||
|
virtual int GetScreenCount() { return 1; }
|
||||||
|
virtual void DrawOnScreen(int s = 0) {}
|
||||||
PD::fvec2 PositionTranslate(PD::fvec2 in) {
|
PD::fvec2 PositionTranslate(PD::fvec2 in) {
|
||||||
return fvec2(in.x * pViewPort.x, in.y * pViewPort.y);
|
return fvec2(in.x * pViewPort.x, in.y * pViewPort.y);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ class HorizonCtr : public PD::OsCtx {
|
|||||||
bool Mainloop() override;
|
bool Mainloop() override;
|
||||||
void ClearViewPort() override;
|
void ClearViewPort() override;
|
||||||
void SwapBuffers() override;
|
void SwapBuffers() override;
|
||||||
|
int GetScreenCount() override { return 2; }
|
||||||
|
void DrawOnScreen(int s) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct Impl;
|
struct Impl;
|
||||||
|
|||||||
@@ -208,10 +208,17 @@ int main(int argc, char** argv) {
|
|||||||
RightStick.pColor = "#00ffff";
|
RightStick.pColor = "#00ffff";
|
||||||
PD::UI7::Context ui7;
|
PD::UI7::Context ui7;
|
||||||
ui7.GetIO().Font = &font;
|
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));
|
ui7.AddViewPort("Default", PD::ivec4(0, 0, 1280, 720));
|
||||||
|
#endif
|
||||||
ui7.UseViewPort("Default");
|
ui7.UseViewPort("Default");
|
||||||
|
bool pMetricsWin = true;
|
||||||
while (pOs->Mainloop()) {
|
while (pOs->Mainloop()) {
|
||||||
PD::TT::End("OSCTX::MainLoop");
|
PD::TT::End("OSCTX::MainLoop");
|
||||||
|
pOs->DrawOnScreen(0);
|
||||||
pOs->ClearViewPort();
|
pOs->ClearViewPort();
|
||||||
PD::TT::Scope __st("MainLoop");
|
PD::TT::Scope __st("MainLoop");
|
||||||
PD::TT::Beg("MainRaw");
|
PD::TT::Beg("MainRaw");
|
||||||
@@ -315,14 +322,18 @@ int main(int argc, char** argv) {
|
|||||||
m->PopFont();
|
m->PopFont();
|
||||||
ui7.EndMenu();
|
ui7.EndMenu();
|
||||||
}
|
}
|
||||||
ui7.MetricsMenu();
|
ui7.MetricsMenu(&pMetricsWin);
|
||||||
|
ui7.StyleEditor();
|
||||||
PD::TT::End("BuildUI7Menus");
|
PD::TT::End("BuildUI7Menus");
|
||||||
PD::TT::Beg("UI7::Context::Update");
|
PD::TT::Beg("UI7::Context::Update");
|
||||||
ui7.Update();
|
ui7.Update();
|
||||||
PD::TT::End("UI7::Context::Update");
|
PD::TT::End("UI7::Context::Update");
|
||||||
PD::Gfx::Reset();
|
PD::Gfx::Reset();
|
||||||
PD::TT::Beg("PD::Gfx::Draw");
|
PD::TT::Beg("PD::Gfx::Draw");
|
||||||
|
pOs->DrawOnScreen(1);
|
||||||
|
pOs->ClearViewPort();
|
||||||
PD::Gfx::Draw(ui7.GetDrawData());
|
PD::Gfx::Draw(ui7.GetDrawData());
|
||||||
|
pOs->DrawOnScreen(0);
|
||||||
PD::Gfx::Draw(pList);
|
PD::Gfx::Draw(pList);
|
||||||
PD::TT::End("PD::Gfx::Draw");
|
PD::TT::End("PD::Gfx::Draw");
|
||||||
pList.Clear();
|
pList.Clear();
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ struct HorizonCtr::Impl {
|
|||||||
C3D_RenderTarget* Top = nullptr;
|
C3D_RenderTarget* Top = nullptr;
|
||||||
C3D_RenderTarget* Bottom = nullptr;
|
C3D_RenderTarget* Bottom = nullptr;
|
||||||
uint32_t* pSocBuf = nullptr;
|
uint32_t* pSocBuf = nullptr;
|
||||||
|
int CurrentScreen = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
void HorizonCtr::Init() {
|
void HorizonCtr::Init() {
|
||||||
@@ -63,13 +64,25 @@ bool HorizonCtr::Mainloop() {
|
|||||||
pViewPort = ivec2(400, 240);
|
pViewPort = ivec2(400, 240);
|
||||||
bool _kill = hidKeysUp() & KEY_START;
|
bool _kill = hidKeysUp() & KEY_START;
|
||||||
C3D_FrameBegin(C3D_FRAME_SYNCDRAW);
|
C3D_FrameBegin(C3D_FRAME_SYNCDRAW);
|
||||||
|
impl->CurrentScreen = 0;
|
||||||
return aptMainLoop() && !_kill;
|
return aptMainLoop() && !_kill;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HorizonCtr::ClearViewPort() {
|
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);
|
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); }
|
void HorizonCtr::SwapBuffers() { C3D_FrameEnd(0); }
|
||||||
|
|||||||
Reference in New Issue
Block a user