Add DrawVertices & FillTriangle funcs.
This commit is contained in:
@@ -1744,3 +1744,41 @@ void Render2D::DrawBlur(const Rectangle& rect, float blurStrength)
|
||||
drawCall.AsBlur.BottomRightY = p.Y;
|
||||
WriteRect(rect, Color::White);
|
||||
}
|
||||
|
||||
void Render2D::DrawVertices(GPUTexture* t, const Array<Vector2> vertices, const Array<Vector2> uvs)
|
||||
{
|
||||
RENDER2D_CHECK_RENDERING_STATE;
|
||||
|
||||
Render2DDrawCall& drawCall = DrawCalls.AddOne();
|
||||
drawCall.Type = DrawCallType::FillTexture;
|
||||
drawCall.StartIB = IBIndex;
|
||||
drawCall.CountIB = vertices.Count();
|
||||
drawCall.AsTexture.Ptr = t;
|
||||
|
||||
for (int32 i = 0; i < vertices.Count(); i += 3)
|
||||
WriteTri(vertices[i], vertices[i + 1], vertices[i + 2], uvs[i], uvs[i + 1], uvs[i + 2]);
|
||||
}
|
||||
|
||||
void Render2D::DrawVertices(const Array<Vector2> vertices, const Array<Color> colors, bool useAlpha)
|
||||
{
|
||||
RENDER2D_CHECK_RENDERING_STATE;
|
||||
|
||||
Render2DDrawCall& drawCall = DrawCalls.AddOne();
|
||||
drawCall.Type = useAlpha ? DrawCallType::FillRect : DrawCallType::FillRectNoAlpha;
|
||||
drawCall.StartIB = IBIndex;
|
||||
drawCall.CountIB = vertices.Count();
|
||||
|
||||
for (int32 i = 0; i < vertices.Count(); i += 3)
|
||||
WriteTri(vertices[i], vertices[i + 1], vertices[i + 2], colors[i], colors[i + 1], colors[i + 2]);
|
||||
}
|
||||
|
||||
void Render2D::FillTriangle(const Vector2& p0, const Vector2& p1, const Vector2& p2, const Color& color)
|
||||
{
|
||||
RENDER2D_CHECK_RENDERING_STATE;
|
||||
|
||||
Render2DDrawCall& drawCall = DrawCalls.AddOne();
|
||||
drawCall.Type = color.A < 1.0f ? DrawCallType::FillRect : DrawCallType::FillRectNoAlpha;
|
||||
drawCall.StartIB = IBIndex;
|
||||
drawCall.CountIB = 3;
|
||||
WriteTri(p0, p1, p2, color, color, color);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include "Engine/Core/Math/Color.h"
|
||||
#include "Engine/Scripting/ScriptingType.h"
|
||||
#include "Engine/Core/Collections/Array.h"
|
||||
|
||||
struct SpriteHandle;
|
||||
struct TextLayoutOptions;
|
||||
@@ -339,4 +340,29 @@ public:
|
||||
/// <param name="rect">The target rectangle to draw (blurs its background).</param>
|
||||
/// <param name="blurStrength">The blur strength defines how blurry the background is. Larger numbers increase blur, resulting in a larger runtime cost on the GPU.</param>
|
||||
API_FUNCTION() static void DrawBlur(const Rectangle& rect, float blurStrength);
|
||||
|
||||
/// <summary>
|
||||
/// Draws vertices array.
|
||||
/// </summary>
|
||||
/// <param name="t">The texture.</param>
|
||||
/// <param name="vertices">The vertices array.</param>
|
||||
/// <param name="uvs">The uvs array.</param>
|
||||
API_FUNCTION() static void DrawVertices(GPUTexture* t, Array<Vector2> vertices, Array<Vector2> uvs);
|
||||
|
||||
/// <summary>
|
||||
/// Draws vertices array.
|
||||
/// </summary>
|
||||
/// <param name="vertices">The vertices array.</param>
|
||||
/// <param name="colors">The colors array.</param>
|
||||
/// <param name="useAlpha">If true alpha blending will be enabled.</param>
|
||||
API_FUNCTION() static void DrawVertices(Array<Vector2> vertices, Array<Color> colors, bool useAlpha);
|
||||
|
||||
/// <summary>
|
||||
/// Fills a triangular area.
|
||||
/// </summary>
|
||||
/// <param name="p0">The first point.</param>
|
||||
/// <param name="p1">The second point.</param>
|
||||
/// <param name="p2">The third point.</param>
|
||||
/// <param name="color">The color.</param>
|
||||
API_FUNCTION() static void FillTriangle(const Vector2& p0, const Vector2& p1, const Vector2& p2, const Color& color);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user