diff --git a/Source/Engine/Render2D/Render2D.cpp b/Source/Engine/Render2D/Render2D.cpp index d85af8f23..705761ae1 100644 --- a/Source/Engine/Render2D/Render2D.cpp +++ b/Source/Engine/Render2D/Render2D.cpp @@ -1932,6 +1932,29 @@ void Render2D::DrawTexturedTriangles(GPUTexture* t, const Span& vertice WriteTri(vertices[i], vertices[i + 1], vertices[i + 2], uvs[i], uvs[i + 1], uvs[i + 2]); } +void Render2D::DrawTexturedTriangles(GPUTexture* t, const Span& vertices, const Span& uvs, const Color& color) +{ + Color colors[3] = {(Color)color, (Color)color, (Color)color}; + Span spancolor(colors, 3); + DrawTexturedTriangles(t, vertices, uvs, spancolor); +} + +void Render2D::DrawTexturedTriangles(GPUTexture* t, const Span& vertices, const Span& uvs, const Span& colors) +{ + CHECK(vertices.Length() == uvs.Length()) + + RENDER2D_CHECK_RENDERING_STATE; + + Render2DDrawCall& drawCall = DrawCalls.AddOne(); + drawCall.Type = DrawCallType::FillTexture; + drawCall.StartIB = IBIndex; + drawCall.CountIB = vertices.Length(); + drawCall.AsTexture.Ptr = t; + + for (int32 i = 0; i < vertices.Length(); i += 3) + WriteTri(vertices[i], vertices[i + 1], vertices[i + 2], uvs[i], uvs[i + 1], uvs[i + 2], colors[i], colors[i + 1], colors[i + 2]); +} + void Render2D::FillTriangles(const Span& vertices, const Span& colors, bool useAlpha) { CHECK(vertices.Length() == colors.Length()); diff --git a/Source/Engine/Render2D/Render2D.h b/Source/Engine/Render2D/Render2D.h index f1c9c816b..118f20107 100644 --- a/Source/Engine/Render2D/Render2D.h +++ b/Source/Engine/Render2D/Render2D.h @@ -402,6 +402,24 @@ public: /// The uvs array. API_FUNCTION() static void DrawTexturedTriangles(GPUTexture* t, const Span& vertices, const Span& uvs); + /// + /// Draws vertices array. + /// + /// The texture. + /// The vertices array. + /// The uvs array. + /// The color. + API_FUNCTION() static void DrawTexturedTriangles(GPUTexture* t, const Span& vertices, const Span& uvs, const Color& color); + + /// + /// Draws vertices array. + /// + /// The texture. + /// The vertices array. + /// The uvs array. + /// The colors array. + API_FUNCTION() static void DrawTexturedTriangles(GPUTexture* t, const Span& vertices, const Span& uvs, const Span& colors); + /// /// Draws vertices array. ///