Upload all my tests
- Add Count<> to AssetManager - Initialize pCode in Shader - Rename linearAllocator to LinearAllocator - Add Construct and destroy to linear allocator - Add Shader unloader (fixes atexit crash i guess) -
This commit is contained in:
@@ -16,7 +16,7 @@ enum LiPathRectFlags_ : Amy::ui {
|
||||
namespace Amy {
|
||||
constexpr auto __pi = std::numbers::pi;
|
||||
|
||||
void Iron::Drawlist::Merge(Iron::Drawlist* list) {
|
||||
void Iron::Drawlist::Merge(Iron::Drawlist *list) {
|
||||
for (size_t i = 0; i < list->pData.size(); i++) {
|
||||
pData.push_back(std::move(list->pData[i]));
|
||||
}
|
||||
@@ -33,7 +33,7 @@ Iron::Command::ref Iron::Drawlist::NewCommand() {
|
||||
return ret;
|
||||
}
|
||||
|
||||
void Iron::Drawlist::clipCmd(Command* ptr) {
|
||||
void Iron::Drawlist::clipCmd(Command *ptr) {
|
||||
if (!ClipRects.empty()) {
|
||||
ptr->ScissorOn = true;
|
||||
ptr->ScissorRect = ivec4(ClipRects.top());
|
||||
@@ -44,7 +44,7 @@ void Iron::Drawlist::Push(Command::ref cmd) { pData.push_back(std::move(cmd)); }
|
||||
|
||||
void Iron::Drawlist::DrawSolid() { pTex = Iron::WhiteTex(); }
|
||||
|
||||
void Iron::Drawlist::PathArcToN(const fvec2& c, float radius, float a_min,
|
||||
void Iron::Drawlist::PathArcToN(const fvec2 &c, float radius, float a_min,
|
||||
float a_max, int segments) {
|
||||
// pathAdd(c)
|
||||
PathReserve(segments + 1);
|
||||
@@ -54,7 +54,7 @@ void Iron::Drawlist::PathArcToN(const fvec2& c, float radius, float a_min,
|
||||
}
|
||||
}
|
||||
|
||||
void Iron::Drawlist::PathFastArcToN(const fvec2& c, float r, float amin,
|
||||
void Iron::Drawlist::PathFastArcToN(const fvec2 &c, float r, float amin,
|
||||
float amax, int s) {
|
||||
/**
|
||||
* Funcion with less division overhead
|
||||
@@ -68,7 +68,7 @@ void Iron::Drawlist::PathFastArcToN(const fvec2& c, float r, float amin,
|
||||
}
|
||||
}
|
||||
|
||||
void Iron::Drawlist::PathRect(const fvec2& a, const fvec2& b, float rounding) {
|
||||
void Iron::Drawlist::PathRect(const fvec2 &a, const fvec2 &b, float rounding) {
|
||||
if (rounding == 0.f) {
|
||||
PathAdd(a);
|
||||
PathAdd(fvec2(b.x, a.y));
|
||||
@@ -100,7 +100,7 @@ void Iron::Drawlist::PathRect(const fvec2& a, const fvec2& b, float rounding) {
|
||||
}
|
||||
}
|
||||
|
||||
void Iron::Drawlist::PathRectEx(const fvec2& a, const fvec2& b, float rounding,
|
||||
void Iron::Drawlist::PathRectEx(const fvec2 &a, const fvec2 &b, float rounding,
|
||||
ui flags) {
|
||||
if (rounding == 0.f) {
|
||||
PathAdd(a);
|
||||
@@ -150,35 +150,35 @@ void Iron::Drawlist::PathRectEx(const fvec2& a, const fvec2& b, float rounding,
|
||||
}
|
||||
}
|
||||
|
||||
void Iron::Drawlist::DrawRect(const fvec2& pos, const fvec2& size, ui color,
|
||||
void Iron::Drawlist::DrawRect(const fvec2 &pos, const fvec2 &size, ui color,
|
||||
int thickness) {
|
||||
PathRect(pos, pos + size);
|
||||
PathStroke(color, thickness, 1);
|
||||
}
|
||||
|
||||
void Iron::Drawlist::DrawRectFilled(const fvec2& pos, const fvec2& size,
|
||||
void Iron::Drawlist::DrawRectFilled(const fvec2 &pos, const fvec2 &size,
|
||||
ui color) {
|
||||
PathRect(pos, pos + size);
|
||||
PathFill(color);
|
||||
}
|
||||
|
||||
void Iron::Drawlist::DrawTriangle(const fvec2& a, const fvec2& b,
|
||||
const fvec2& c, ui color, int thickness) {
|
||||
void Iron::Drawlist::DrawTriangle(const fvec2 &a, const fvec2 &b,
|
||||
const fvec2 &c, ui color, int thickness) {
|
||||
PathAdd(a);
|
||||
PathAdd(b);
|
||||
PathAdd(c);
|
||||
PathStroke(color, thickness, 1);
|
||||
}
|
||||
|
||||
void Iron::Drawlist::DrawTriangleFilled(const fvec2& a, const fvec2& b,
|
||||
const fvec2& c, ui color) {
|
||||
void Iron::Drawlist::DrawTriangleFilled(const fvec2 &a, const fvec2 &b,
|
||||
const fvec2 &c, ui color) {
|
||||
PathAdd(a);
|
||||
PathAdd(b);
|
||||
PathAdd(c);
|
||||
PathFill(color);
|
||||
}
|
||||
|
||||
void Iron::Drawlist::DrawCircle(const fvec2& center, float rad, ui color,
|
||||
void Iron::Drawlist::DrawCircle(const fvec2 ¢er, float rad, ui color,
|
||||
int segments, int thickness) {
|
||||
if (segments <= 0) {
|
||||
// Auto Segment
|
||||
@@ -186,11 +186,11 @@ void Iron::Drawlist::DrawCircle(const fvec2& center, float rad, ui color,
|
||||
float am = (__pi * 2.0f) * ((float)segments) / (float)segments;
|
||||
PathArcToN(center, rad, 0.f, am, segments);
|
||||
}
|
||||
DrawSolid(); // Only Solid Color Supported
|
||||
DrawSolid(); // Only Solid Color Supported
|
||||
PathStroke(color, thickness, 1);
|
||||
}
|
||||
|
||||
void Iron::Drawlist::DrawCircleFilled(const fvec2& center, float rad, ui color,
|
||||
void Iron::Drawlist::DrawCircleFilled(const fvec2 ¢er, float rad, ui color,
|
||||
int segments) {
|
||||
if (segments <= 0) {
|
||||
// Auto Segment
|
||||
@@ -201,7 +201,7 @@ void Iron::Drawlist::DrawCircleFilled(const fvec2& center, float rad, ui color,
|
||||
PathFill(color);
|
||||
}
|
||||
|
||||
void Iron::Drawlist::DrawPolyLine(const std::vector<fvec2>& points, ui clr,
|
||||
void Iron::Drawlist::DrawPolyLine(const std::vector<fvec2> &points, ui clr,
|
||||
ui flags, int thickness) {
|
||||
if (points.size() < 2) {
|
||||
return;
|
||||
@@ -223,17 +223,17 @@ void Iron::Drawlist::DrawPolyLine(const std::vector<fvec2>& points, ui clr,
|
||||
Push(std::move(cmd));
|
||||
}
|
||||
|
||||
void Iron::Drawlist::DrawConvexPolyFilled(const std::vector<fvec2>& points,
|
||||
void Iron::Drawlist::DrawConvexPolyFilled(const std::vector<fvec2> &points,
|
||||
ui clr) {
|
||||
if (points.size() < 3) {
|
||||
return; // Need at least three points
|
||||
return; // Need at least three points
|
||||
}
|
||||
auto cmd = NewCommand();
|
||||
CmdConvexPolyFilled(cmd.get(), points, clr, pTex);
|
||||
Push(std::move(cmd));
|
||||
}
|
||||
|
||||
void Iron::Drawlist::DrawText(const fvec2& pos, const std::string& text,
|
||||
void Iron::Drawlist::DrawText(const fvec2 &pos, const std::string &text,
|
||||
ui color) {
|
||||
/*if (!pCurrentFont) {
|
||||
return;
|
||||
@@ -247,8 +247,8 @@ void Iron::Drawlist::DrawText(const fvec2& pos, const std::string& text,
|
||||
}*/
|
||||
}
|
||||
|
||||
void Iron::Drawlist::DrawTextEx(const fvec2& p, const std::string& text,
|
||||
ui color, ui flags, const fvec2& box) {
|
||||
void Iron::Drawlist::DrawTextEx(const fvec2 &p, const std::string &text,
|
||||
ui color, ui flags, const fvec2 &box) {
|
||||
/*if (!pCurrentFont) {
|
||||
return;
|
||||
}
|
||||
@@ -261,9 +261,9 @@ void Iron::Drawlist::DrawTextEx(const fvec2& p, const std::string& text,
|
||||
}*/
|
||||
}
|
||||
|
||||
void Iron::Drawlist::DrawLine(const fvec2& a, const fvec2& b, ui color, int t) {
|
||||
void Iron::Drawlist::DrawLine(const fvec2 &a, const fvec2 &b, ui color, int t) {
|
||||
PathAdd(a);
|
||||
PathAdd(b);
|
||||
PathStroke(color, t);
|
||||
}
|
||||
} // namespace Amy
|
||||
} // namespace Amy
|
||||
@@ -57,13 +57,14 @@ unsigned char li_shader[] = {
|
||||
};
|
||||
// clang-format on
|
||||
size_t li_shader_size = 0x124;
|
||||
std::vector<Iron::Vertex, linearAllocator<Iron::Vertex>> Iron::m_vbuf;
|
||||
std::vector<u16, linearAllocator<u16>> Iron::m_ibuf;
|
||||
std::vector<Iron::Vertex, LinearAllocator<Iron::Vertex>> Iron::m_vbuf;
|
||||
std::vector<u16, LinearAllocator<u16>> Iron::m_ibuf;
|
||||
int Iron::uLocProj = 0;
|
||||
C3D::Shader* Iron::m_shader = nullptr;
|
||||
mat4 Iron::m_mtx;
|
||||
int Iron::m_idx = 0, Iron::m_vtx = 0;
|
||||
Texture* Iron::m_solid = nullptr;
|
||||
C3D_Mtx __m;
|
||||
|
||||
void Iron::Init() {
|
||||
pSetupShader();
|
||||
@@ -79,9 +80,13 @@ void Iron::NewFrame() {
|
||||
|
||||
void Iron::DrawOn(C3D::Screen* screen) {
|
||||
m_shader->Use();
|
||||
m_mtx = mat4::ortho(0.f, (float)screen->Width(), (float)screen->Height(), 0.f,
|
||||
1.f, -1.f);
|
||||
m_shader->SetMat4(uLocProj, m_mtx);
|
||||
Mtx_Identity(&__m);
|
||||
Mtx_OrthoTilt(&__m, 0, (float)screen->Width(), (float)screen->Height(), 0.f,
|
||||
1.f, -1.f, true);
|
||||
// m_mtx = mat4::ortho(0.f, (float)screen->Width(), (float)screen->Height(),
|
||||
// 0.f,
|
||||
// 1.f, -1.f);
|
||||
m_shader->SetMat4(uLocProj, &__m);
|
||||
}
|
||||
|
||||
void Iron::Draw(const std::vector<Iron::Command::ref>& data) {
|
||||
@@ -148,11 +153,11 @@ void Iron::pSetupShader() {
|
||||
AttrInfo_AddLoader(&m_shader->pInfo, 0, GPU_FLOAT, 2);
|
||||
AttrInfo_AddLoader(&m_shader->pInfo, 1, GPU_FLOAT, 2);
|
||||
AttrInfo_AddLoader(&m_shader->pInfo, 2, GPU_UNSIGNED_BYTE, 4);
|
||||
// m_shader->Load("romfs:/shaders/lithium.shbin");
|
||||
// m_shader->Compile(__ironshader__);
|
||||
// m_shader->Input(GPU_FLOAT, 2); // pos
|
||||
// m_shader->Input(GPU_FLOAT, 2); // uv
|
||||
// m_shader->Input(GPU_UNSIGNED_BYTE, 4); // color
|
||||
/* m_shader->Load("romfs:/shaders/lithium.shbin");
|
||||
// m_shader->Compile(__ironshader__);
|
||||
m_shader->Input(GPU_FLOAT, 2); // pos
|
||||
m_shader->Input(GPU_FLOAT, 2); // uv
|
||||
m_shader->Input(GPU_UNSIGNED_BYTE, 4); // color*/
|
||||
uLocProj = m_shader->loc("projection");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user