From b4b1144c6041621bc2ae3d131f4a179aff9edff3 Mon Sep 17 00:00:00 2001 From: tobid7 Date: Tue, 30 Dec 2025 22:28:03 +0100 Subject: [PATCH] Implemet CutTex Rendering --- include/amethyst/iron.hpp | 8 ++++++++ source/iron/drawlist.cpp | 11 +++++++++++ 2 files changed, 19 insertions(+) diff --git a/include/amethyst/iron.hpp b/include/amethyst/iron.hpp index 16ef130..3c39249 100644 --- a/include/amethyst/iron.hpp +++ b/include/amethyst/iron.hpp @@ -122,6 +122,14 @@ class Iron { void DrawSolid(); 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 SetFontScale(float v) { pFontScale = v; } float GetFontScale() { return pFontScale; } diff --git a/source/iron/drawlist.cpp b/source/iron/drawlist.cpp index b65abb0..0a246b3 100644 --- a/source/iron/drawlist.cpp +++ b/source/iron/drawlist.cpp @@ -209,6 +209,17 @@ void Iron::Drawlist::DrawCircleFilled(const fvec2& center, float rad, ui 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& points, ui clr, ui flags, int thickness) { if (points.size() < 2) {