Implemet CutTex Rendering

This commit is contained in:
2025-12-30 22:28:03 +01:00
parent 6e502d73d8
commit b4b1144c60
2 changed files with 19 additions and 0 deletions

View File

@@ -122,6 +122,14 @@ class Iron {
void DrawSolid(); void DrawSolid();
void DrawTex(Texture::Ref tex) { pTex = tex; } void DrawTex(Texture::Ref tex) { pTex = tex; }
void DrawCutTex(fvec2 pos, fvec2 size, fvec4 cut_rect,
ui color = 0xffffffff);
void DrawCutTex(fvec2 pos, fvec2 size, fvec4 cut_rect, Texture::Ref tex,
ui color = 0xffffffff) {
DrawTex(tex);
DrawCutTex(pos, size, cut_rect, color);
DrawSolid();
}
void SetFont(Font::Ref fnt) { pCurrentFont = fnt; } void SetFont(Font::Ref fnt) { pCurrentFont = fnt; }
void SetFontScale(float v) { pFontScale = v; } void SetFontScale(float v) { pFontScale = v; }
float GetFontScale() { return pFontScale; } float GetFontScale() { return pFontScale; }

View File

@@ -209,6 +209,17 @@ void Iron::Drawlist::DrawCircleFilled(const fvec2& center, float rad, ui color,
PathFill(color); PathFill(color);
} }
void Iron::Drawlist::DrawCutTex(fvec2 pos, fvec2 size, fvec4 cut_rect,
ui color) {
auto r = Iron::PrimRect(pos, size);
auto cmd = NewCommand();
auto uv = cut_rect / fvec4(pTex->Size(), pTex->Size());
uv.y = 1.f - uv.y;
uv.w = 1.f - uv.w;
Iron::CmdQuad(cmd.get(), r, uv, color);
Push(std::move(cmd));
}
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) { ui flags, int thickness) {
if (points.size() < 2) { if (points.size() < 2) {