Layers are back

This commit is contained in:
2026-09-06 14:39:28 +02:00
parent 9e27dfb0eb
commit e8a9055090
3 changed files with 17 additions and 1 deletions
+5
View File
@@ -42,6 +42,10 @@ class PD_API Drawlist {
void Copy(Drawlist& other); void Copy(Drawlist& other);
void Optimize(); void Optimize();
void Clear(); void Clear();
void SetLayer(int layer) { pCurrentLayer = layer; }
void LayerUp() { pCurrentLayer++; }
void LayerDown() { pCurrentLayer--; }
int GetLayer() const { return pCurrentLayer; }
size_t GetNumVertices() const { size_t GetNumVertices() const {
size_t count = 0; size_t count = 0;
@@ -126,6 +130,7 @@ class PD_API Drawlist {
private: private:
Texture pCurrentTexture; Texture pCurrentTexture;
int pCurrentLayer = 0;
Pool<Command> pCommands; Pool<Command> pCommands;
Pool<fvec2> pPath; Pool<fvec2> pPath;
Pool<Vertex> pVertices; Pool<Vertex> pVertices;
+10
View File
@@ -12,12 +12,20 @@ PD_API Drawlist::Drawlist() { Clear(); }
PD_API Drawlist::~Drawlist() { Clear(); } PD_API Drawlist::~Drawlist() { Clear(); }
PD_API void Drawlist::Merge(Drawlist& other) { PD_API void Drawlist::Merge(Drawlist& other) {
size_t start = pCommands.size();
pCommands.AppendMove(other.pCommands); pCommands.AppendMove(other.pCommands);
for (size_t i = start; i < pCommands.size(); i++) {
pCommands[i].Layer += this->pCurrentLayer;
}
other.Clear(); other.Clear();
} }
PD_API void Drawlist::Copy(Drawlist& other) { PD_API void Drawlist::Copy(Drawlist& other) {
int start = pCommands.size();
pCommands.AppendCopy(other.pCommands); pCommands.AppendCopy(other.pCommands);
for (size_t i = start; i < pCommands.size(); i++) {
pCommands[i].Layer += this->pCurrentLayer;
}
} }
PD_API void Drawlist::Optimize() { PD_API void Drawlist::Optimize() {
@@ -34,12 +42,14 @@ PD_API void Drawlist::Clear() {
UnbindTexture(); UnbindTexture();
pPath.ResetFast(); pPath.ResetFast();
pCommands.NoReset(); pCommands.NoReset();
pCurrentLayer = 0;
} }
/** Command Allocation */ /** Command Allocation */
PD_API Command& Drawlist::NewCommand() { PD_API Command& Drawlist::NewCommand() {
auto cmd = pCommands.Allocate(1); auto cmd = pCommands.Allocate(1);
cmd->Reset(); cmd->Reset();
cmd->Layer = pCurrentLayer;
cmd->Tex = pCurrentTexture.GetID(); cmd->Tex = pCurrentTexture.GetID();
return *cmd; return *cmd;
} }
+2 -1
View File
@@ -288,7 +288,8 @@ PD_API void Font::CmdTextEx(Drawlist& dl, const fvec2& pos, u32 color,
} }
if (cp.Size.x > 0 && cp.Size.y > 0) { if (cp.Size.x > 0 && cp.Size.y > 0) {
if (cmd == nullptr || cmd->Tex != Textures[cp.Tex]) { if (cmd == nullptr || cmd->Tex != Textures[cp.Tex] ||
cmd->Layer != dl.GetLayer()) {
if (cp.Tex >= Textures.size()) continue; if (cp.Tex >= Textures.size()) continue;
cmd = &dl.NewCommand(); cmd = &dl.NewCommand();
cmd->Tex = Textures[cp.Tex]; cmd->Tex = Textures[cp.Tex];