Actually implement ultra-rendering
This commit is contained in:
@@ -17,6 +17,7 @@ class PD_API ElementBase {
|
|||||||
* Reset Function (for PD::Pool::FastReset)
|
* Reset Function (for PD::Pool::FastReset)
|
||||||
*/
|
*/
|
||||||
virtual void Reset() {}
|
virtual void Reset() {}
|
||||||
|
void Update();
|
||||||
|
|
||||||
void SetAlignment(UltraAlignment a) { pAlignment = a; }
|
void SetAlignment(UltraAlignment a) { pAlignment = a; }
|
||||||
void SetPosition(const PD::fvec2& pos) { pPos = pos; }
|
void SetPosition(const PD::fvec2& pos) { pPos = pos; }
|
||||||
@@ -33,6 +34,7 @@ class PD_API ElementBase {
|
|||||||
UltraAlignment pAlignment = 0;
|
UltraAlignment pAlignment = 0;
|
||||||
PD::fvec2 pPos;
|
PD::fvec2 pPos;
|
||||||
PD::fvec2 pSize;
|
PD::fvec2 pSize;
|
||||||
|
PD::Li::Rect pRenderspace;
|
||||||
};
|
};
|
||||||
} // namespace Ultra
|
} // namespace Ultra
|
||||||
} // namespace PD
|
} // namespace PD
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#include <pd/ultra/canvas.hpp>
|
#include <pd/ultra/container.hpp>
|
||||||
#include <pd/ultra/elems/element.hpp>
|
#include <pd/ultra/elems/element.hpp>
|
||||||
|
|
||||||
namespace PD {
|
namespace PD {
|
||||||
@@ -11,5 +11,10 @@ PD_API bool ElementBase::RevisionUpdate(PD::u32 req) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
PD_API void ElementBase::Update() {
|
||||||
|
if (!pParent) pRenderspace = PD::fvec4(pPos, pPos + pSize);
|
||||||
|
pRenderspace = PD::fvec4(pParent->GetTopLeft() + pPos,
|
||||||
|
pParent->GetTopLeft() + pPos + pSize);
|
||||||
|
}
|
||||||
} // namespace Ultra
|
} // namespace Ultra
|
||||||
} // namespace PD
|
} // namespace PD
|
||||||
@@ -3,9 +3,9 @@
|
|||||||
namespace PD {
|
namespace PD {
|
||||||
namespace Ultra {
|
namespace Ultra {
|
||||||
PD_API void Image::Draw(PD::Li::Drawlist& l) {
|
PD_API void Image::Draw(PD::Li::Drawlist& l) {
|
||||||
// l.BindTexture(*pTex);
|
l.BindTexture(*pTex);
|
||||||
// l.PathRect(pRenderspace.TopLeft(), pRenderspace.BotRight(), pRounding);
|
l.PathRect(pRenderspace.TopLeft(), pRenderspace.BotRight(), pRounding);
|
||||||
// l.PathFill(pColor);
|
l.PathFill(pColor);
|
||||||
}
|
}
|
||||||
} // namespace Ultra
|
} // namespace Ultra
|
||||||
} // namespace PD
|
} // namespace PD
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
namespace PD {
|
namespace PD {
|
||||||
namespace Ultra {
|
namespace Ultra {
|
||||||
PD_API void Rect::Draw(PD::Li::Drawlist& l) {
|
PD_API void Rect::Draw(PD::Li::Drawlist& l) {
|
||||||
l.PathRect(pPos, pPos + pSize, pRounding);
|
l.PathRect(pRenderspace.TopLeft(), pRenderspace.BotRight(), pRounding);
|
||||||
if (pLined) {
|
if (pLined) {
|
||||||
l.PathStroke(pColor, pThickness, LiDrawFlags_Close);
|
l.PathStroke(pColor, pThickness, LiDrawFlags_Close);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
namespace PD {
|
namespace PD {
|
||||||
namespace Ultra {
|
namespace Ultra {
|
||||||
PD_API void Text::Draw(PD::Li::Drawlist& l) {
|
PD_API void Text::Draw(PD::Li::Drawlist& l) {
|
||||||
l.DrawText(pPos, pText.c_str(), pColor);
|
l.DrawText(pRenderspace.TopLeft(), pText.c_str(), pColor);
|
||||||
}
|
}
|
||||||
} // namespace Ultra
|
} // namespace Ultra
|
||||||
} // namespace PD
|
} // namespace PD
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#include <pd/lithium/formatters.hpp>
|
||||||
#include <pd/ultra/layout.hpp>
|
#include <pd/ultra/layout.hpp>
|
||||||
|
|
||||||
namespace PD {
|
namespace PD {
|
||||||
@@ -7,8 +8,12 @@ PD_API void Layout::SetFont(PD::Li::Font& font) { pList.SetFont(&font); }
|
|||||||
PD_API void Layout::Render() {
|
PD_API void Layout::Render() {
|
||||||
pList.Clear();
|
pList.Clear();
|
||||||
for (auto& it : GetElements()) {
|
for (auto& it : GetElements()) {
|
||||||
|
it->Update();
|
||||||
it->Draw(pList);
|
it->Draw(pList);
|
||||||
}
|
}
|
||||||
|
pList.DrawText(PD::fvec2(5, GetBotLeft().y - 40),
|
||||||
|
std::format("Lyt: [{}]", GetRenderspace()).c_str(),
|
||||||
|
0xffff00ff);
|
||||||
}
|
}
|
||||||
} // namespace Ultra
|
} // namespace Ultra
|
||||||
} // namespace PD
|
} // namespace PD
|
||||||
@@ -59,10 +59,10 @@ int main(int argc, char** argv) {
|
|||||||
r.SetPosition(250, 150);
|
r.SetPosition(250, 150);
|
||||||
r.SetSize(100, 70);
|
r.SetSize(100, 70);
|
||||||
PD::Ultra::Rect rr;
|
PD::Ultra::Rect rr;
|
||||||
r.SetColor(0xff0000ff);
|
rr.SetColor(0x880000ff);
|
||||||
r.SetRounding(10.f);
|
rr.SetRounding(10.f);
|
||||||
r.SetPosition(250, 150);
|
rr.SetPosition(250, 150);
|
||||||
r.SetSize(100, 70);
|
rr.SetSize(100, 70);
|
||||||
lyt.Push(&rr);
|
lyt.Push(&rr);
|
||||||
lyt.Push(&r);
|
lyt.Push(&r);
|
||||||
PD::Ultra::Text txt;
|
PD::Ultra::Text txt;
|
||||||
@@ -72,6 +72,7 @@ int main(int argc, char** argv) {
|
|||||||
lyt.Push(&txt);
|
lyt.Push(&txt);
|
||||||
while (pOs->Mainloop()) {
|
while (pOs->Mainloop()) {
|
||||||
pOs->ClearViewPort();
|
pOs->ClearViewPort();
|
||||||
|
lyt.SetViewport(pOs->GetViewport());
|
||||||
PD::Li::ResetPools();
|
PD::Li::ResetPools();
|
||||||
pList.DrawRectFilled(150, 50, 0x88ffffff);
|
pList.DrawRectFilled(150, 50, 0x88ffffff);
|
||||||
pList.DrawRect(150, 50, 0xffffffff);
|
pList.DrawRect(150, 50, 0xffffffff);
|
||||||
|
|||||||
Reference in New Issue
Block a user