Remove custom standard lib

Why?? cause it was russian roulette with pointer access stuff etc
This commit is contained in:
2025-12-17 10:02:05 +01:00
parent 66d3825481
commit 803fa5cdb5
27 changed files with 78 additions and 840 deletions

View File

@@ -37,20 +37,22 @@ PD_LITHIUM_API void DrawList::Clear() {
pNumIndices = 0;
pNumVertices = 0;
pDrawList.clear();
pPath.Clear();
pClipRects.Clear();
pPath.clear();
while (!pClipRects.empty()) {
pClipRects.pop();
}
}
PD_LITHIUM_API void DrawList::AddCommand(Command::Ref v) {
pNumIndices += v->IndexBuffer.Size();
pNumVertices += v->VertexBuffer.Size();
pNumIndices += v->IndexBuffer.size();
pNumVertices += v->VertexBuffer.size();
pDrawList.push_back(std::move(v));
}
PD_LITHIUM_API void DrawList::Merge(DrawList::Ref list) {
for (size_t i = 0; i < list->pDrawList.size(); i++) {
pNumIndices += list->pDrawList[i]->IndexBuffer.Size();
pNumVertices += list->pDrawList[i]->VertexBuffer.Size();
pNumIndices += list->pDrawList[i]->IndexBuffer.size();
pNumVertices += list->pDrawList[i]->VertexBuffer.size();
pDrawList.push_back(std::move(list->pDrawList[i]));
}
/** Make sure The list gets cleared */
@@ -67,9 +69,9 @@ PD_LITHIUM_API Command::Ref DrawList::PreGenerateCmd() {
}
PD_LITHIUM_API void DrawList::pClipCmd(Command *cmd) {
if (!pClipRects.IsEmpty()) {
if (!pClipRects.empty()) {
cmd->ScissorOn = true;
cmd->ScissorRect = ivec4(pClipRects.Top());
cmd->ScissorRect = ivec4(pClipRects.top());
}
}
@@ -233,21 +235,21 @@ PD_LITHIUM_API void DrawList::DrawCircleFilled(const fvec2 &center, float rad,
}
// TODO: Don't render OOS
PD_LITHIUM_API void DrawList::DrawPolyLine(const Vec<fvec2> &points, u32 clr,
u32 flags, int thickness) {
if (points.Size() < 2) {
PD_LITHIUM_API void DrawList::DrawPolyLine(const std::vector<fvec2> &points,
u32 clr, u32 flags, int thickness) {
if (points.size() < 2) {
return;
}
DrawSolid();
auto cmd = PreGenerateCmd();
bool close = (flags & (1 << 0));
int num_points = close ? (int)points.Size() : (int)points.Size() - 1;
int num_points = close ? (int)points.size() : (int)points.size() - 1;
if (flags & (1 << 1)) {
// TODO: Find a way to draw less garbage looking lines
} else {
// Non antialiased lines look awful when rendering with thickness != 1
for (int i = 0; i < num_points; i++) {
int j = (i + 1) == (int)points.Size() ? 0 : (i + 1);
int j = (i + 1) == (int)points.size() ? 0 : (i + 1);
auto line = Renderer::PrimLine(points[i], points[j], thickness);
Renderer::CmdQuad(cmd.get(), line, vec4(0.f, 1.f, 1.f, 0.f), clr);
}
@@ -255,9 +257,9 @@ PD_LITHIUM_API void DrawList::DrawPolyLine(const Vec<fvec2> &points, u32 clr,
AddCommand(std::move(cmd));
}
PD_LITHIUM_API void DrawList::DrawConvexPolyFilled(const Vec<fvec2> &points,
u32 clr) {
if (points.Size() < 3) {
PD_LITHIUM_API void DrawList::DrawConvexPolyFilled(
const std::vector<fvec2> &points, u32 clr) {
if (points.size() < 3) {
return; // Need at least three points
}
auto cmd = PreGenerateCmd();

View File

@@ -110,10 +110,9 @@ PD_LITHIUM_API void Renderer::CmdTriangle(Command* cmd, const fvec2 a,
// TODO: Don't render OOS (Probably make it with a define as it
// would probably be faster to render out of screen than checking if
// it could be skipped)
PD_LITHIUM_API void Renderer::CmdConvexPolyFilled(Command* cmd,
const Vec<fvec2>& points,
u32 clr, Texture::Ref tex) {
if (points.Size() < 3 || tex == nullptr) {
PD_LITHIUM_API void Renderer::CmdConvexPolyFilled(
Command* cmd, const std::vector<fvec2>& points, u32 clr, Texture::Ref tex) {
if (points.size() < 3 || tex == nullptr) {
return; // Need at least three points
}
@@ -121,11 +120,11 @@ PD_LITHIUM_API void Renderer::CmdConvexPolyFilled(Command* cmd,
float minX = points[0].x, minY = points[0].y;
float maxX = minX, maxY = minY;
// Check for the max and min Positions
for (auto it = points.Begin(); it != points.End(); it++) {
if ((*it).x < minX) minX = (*it).x;
if ((*it).y < minY) minY = (*it).y;
if ((*it).x > maxX) maxX = (*it).x;
if ((*it).y > maxY) maxY = (*it).y;
for (const auto& it : points) {
if (it.x < minX) minX = it.x;
if (it.y < minY) minY = it.y;
if (it.x > maxX) maxX = it.x;
if (it.y > maxY) maxY = it.y;
}
// Get Short defines for UV
// (Bottom Right is not required)
@@ -134,10 +133,10 @@ PD_LITHIUM_API void Renderer::CmdConvexPolyFilled(Command* cmd,
auto uv_bl = tex->UV.BotLeft();
// Render
for (int i = 2; i < (int)points.Size(); i++) {
for (int i = 2; i < (int)points.size(); i++) {
cmd->AddIdx(0).AddIdx(i).AddIdx(i - 1);
}
for (int i = 0; i < (int)points.Size(); i++) {
for (int i = 0; i < (int)points.size(); i++) {
// Calculate U and V coords
float u =
uv_tl.x + ((points[i].x - minX) / (maxX - minX)) * (uv_tr.x - uv_tl.x);