From 19ee939c5d105d9c57da1be920b7b7c912bed675 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Perrier Date: Wed, 1 Sep 2021 06:57:41 +0200 Subject: [PATCH 1/2] Add Render2D::DrawTexturedTriangles variations --- Source/Engine/Render2D/Render2D.cpp | 23 +++++++++++++++++++++++ Source/Engine/Render2D/Render2D.h | 18 ++++++++++++++++++ 2 files changed, 41 insertions(+) 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..4f5558da0 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. /// From ad0c39e4ac2beadfa71431dee8d745fe35d453e6 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Perrier Date: Wed, 1 Sep 2021 08:58:15 +0200 Subject: [PATCH 2/2] Typo --- Source/Engine/Render2D/Render2D.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Engine/Render2D/Render2D.h b/Source/Engine/Render2D/Render2D.h index 4f5558da0..118f20107 100644 --- a/Source/Engine/Render2D/Render2D.h +++ b/Source/Engine/Render2D/Render2D.h @@ -408,7 +408,7 @@ public: /// The texture. /// The vertices array. /// The uvs array. - /// /// The color. + /// The color. API_FUNCTION() static void DrawTexturedTriangles(GPUTexture* t, const Span& vertices, const Span& uvs, const Color& color); /// @@ -417,7 +417,7 @@ public: /// The texture. /// The vertices array. /// The uvs array. - /// /// The colors array. + /// The colors array. API_FUNCTION() static void DrawTexturedTriangles(GPUTexture* t, const Span& vertices, const Span& uvs, const Span& colors); ///