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