Remove custom standard lib
Why?? cause it was russian roulette with pointer access stuff etc
This commit is contained in:
@@ -79,59 +79,4 @@ PD_IMAGE_API void ReverseBuf(std::vector<u8> &buf, size_t bpp, int w, int h) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PD_IMAGE_API void RGB24toRGBA32(PD::Vec<u8> &out, const PD::Vec<u8> &in,
|
||||
const int &w, const int &h) {
|
||||
// Converts RGB24 to RGBA32
|
||||
for (int y = 0; y < h; y++) {
|
||||
for (int x = 0; x < w; x++) {
|
||||
int src = (y * w + x) * 3;
|
||||
int dst = (y * w + x) * 4;
|
||||
out[dst + 0] = in[src + 0];
|
||||
out[dst + 1] = in[src + 1];
|
||||
out[dst + 2] = in[src + 2];
|
||||
out[dst + 3] = 255;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PD_IMAGE_API void RGB32toRGBA24(PD::Vec<u8> &out, const PD::Vec<u8> &in,
|
||||
const int &w, const int &h) {
|
||||
// Converts RGB24 to RGBA32
|
||||
for (int y = 0; y < h; y++) {
|
||||
for (int x = 0; x < w; x++) {
|
||||
int src = (y * w + x) * 4;
|
||||
int dst = (y * w + x) * 3;
|
||||
out[dst + 0] = in[src + 0];
|
||||
out[dst + 1] = in[src + 1];
|
||||
out[dst + 2] = in[src + 2];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PD_IMAGE_API void Reverse32(PD::Vec<u8> &buf, const int &w, const int &h) {
|
||||
for (int x = 0; x < w; x++) {
|
||||
for (int y = 0; y < h; y++) {
|
||||
int i = y * w + x;
|
||||
u8 t0 = buf[i + 0];
|
||||
u8 t1 = buf[i + 1];
|
||||
buf[i + 0] = buf[i + 3];
|
||||
buf[i + 1] = buf[i + 2];
|
||||
buf[i + 3] = t0;
|
||||
buf[i + 2] = t1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PD_IMAGE_API void ReverseBuf(PD::Vec<u8> &buf, size_t bpp, int w, int h) {
|
||||
PD::Vec<u8> cpy = buf;
|
||||
for (int x = 0; x < w; x++) {
|
||||
for (int y = 0; y < h; y++) {
|
||||
int pos = (y * w + x) * bpp;
|
||||
for (size_t i = 0; i < bpp; i++) {
|
||||
buf[pos + bpp - 1 - i] = cpy[pos + i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace PD::ImgConvert
|
||||
@@ -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 ¢er, 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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -34,9 +34,8 @@ PD_UI7_API void UI7::IO::Update() {
|
||||
Time->Update();
|
||||
InputHandler->Update();
|
||||
Framerate = 1000.f / Delta;
|
||||
DrawListRegestry.Clear();
|
||||
DrawListRegestry.PushFront(
|
||||
Pair<UI7::ID, Li::DrawList::Ref>("CtxBackList", Back));
|
||||
DrawListRegestry.clear();
|
||||
DrawListRegestry.push_front(std::make_pair("CtxBackList", Back));
|
||||
// RegisterDrawList("CtxBackList", Back);
|
||||
NumIndices = FDL->pNumIndices;
|
||||
NumVertices = FDL->pNumVertices;
|
||||
|
||||
@@ -66,7 +66,7 @@ PD_UI7_API void Layout::AddObject(Container::Ref obj) {
|
||||
obj->Update();
|
||||
CursorMove(obj->GetSize());
|
||||
obj->HandleScrolling(ScrollOffset, WorkRect);
|
||||
Objects.PushBack(obj);
|
||||
Objects.push_back(obj);
|
||||
}
|
||||
|
||||
PD_UI7_API void Layout::AddObjectEx(Container::Ref obj, u32 flags) {
|
||||
@@ -83,9 +83,9 @@ PD_UI7_API void Layout::AddObjectEx(Container::Ref obj, u32 flags) {
|
||||
obj->HandleScrolling(ScrollOffset, WorkRect);
|
||||
}
|
||||
if (flags & UI7LytAdd_Front) {
|
||||
Objects.PushFront(obj);
|
||||
Objects.push_front(obj);
|
||||
} else {
|
||||
Objects.PushBack(obj);
|
||||
Objects.push_back(obj);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ PD_UI7_API void Layout::Update() {
|
||||
for (auto& it : tbr) {
|
||||
IDObjects.erase(IDObjects.begin() + it);
|
||||
}
|
||||
Objects.Clear();
|
||||
Objects.clear();
|
||||
WorkRect = fvec4(fvec2(WorkRect.x, WorkRect.y), Size - IO->MenuPadding);
|
||||
CursorInit();
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ PD_UI7_API void Menu::Label(const std::string& label) {
|
||||
PD_UI7_API bool Menu::Button(const std::string& label) {
|
||||
bool ret = false;
|
||||
u32 id = Strings::FastHash("btn" + label +
|
||||
std::to_string(pLayout->Objects.Size()));
|
||||
std::to_string(pLayout->Objects.size()));
|
||||
Container::Ref r = pLayout->FindObject(id);
|
||||
if (!r) {
|
||||
r = Button::New(label, pIO);
|
||||
@@ -59,7 +59,7 @@ PD_UI7_API bool Menu::Button(const std::string& label) {
|
||||
|
||||
PD_UI7_API void Menu::Checkbox(const std::string& label, bool& v) {
|
||||
u32 id = Strings::FastHash("cbx" + label +
|
||||
std::to_string(pLayout->Objects.Size()));
|
||||
std::to_string(pLayout->Objects.size()));
|
||||
Container::Ref r = pLayout->FindObject(id);
|
||||
if (!r) {
|
||||
r = Checkbox::New(label, v, pIO);
|
||||
|
||||
@@ -272,7 +272,7 @@ PD_UI7_API void Context::MetricsMenu(bool *show) {
|
||||
}
|
||||
// Well this are Li Drawlists now and they do not count their stats (yet)
|
||||
/*if (m->BeginTreeNode("DrawLists (" +
|
||||
std::to_string(pIO->DrawListRegestry.Size()) + ")")) {
|
||||
std::to_string(pIO->DrawListRegestry.size()) + ")")) {
|
||||
for (auto &it : pIO->DrawListRegestry) {
|
||||
if (m->BeginTreeNode(it.First.GetName())) {
|
||||
m->Label("Vertices: " + std::to_string(it.Second->NumVertices));
|
||||
|
||||
Reference in New Issue
Block a user