diff options
| author | Ray <[email protected]> | 2019-06-17 10:29:58 +0200 |
|---|---|---|
| committer | Ray <[email protected]> | 2019-06-17 10:29:58 +0200 |
| commit | e0854696b4685737f21b0b2b973104c76c5bb8ef (patch) | |
| tree | 7afe5373a35f36fbc58d93201645f38d4472acbc /src/shapes.c | |
| parent | f951f0c53667ea9d1b195343de3bfa9fbabe60ab (diff) | |
| download | raylib-e0854696b4685737f21b0b2b973104c76c5bb8ef.tar.gz raylib-e0854696b4685737f21b0b2b973104c76c5bb8ef.zip | |
ADDED: DrawTriangleStrip()
Diffstat (limited to 'src/shapes.c')
| -rw-r--r-- | src/shapes.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/shapes.c b/src/shapes.c index bab8a5a4..190bd4e1 100644 --- a/src/shapes.c +++ b/src/shapes.c @@ -1181,6 +1181,8 @@ void DrawRectangleRoundedLines(Rectangle rec, float roundness, int segments, int // Draw a triangle void DrawTriangle(Vector2 v1, Vector2 v2, Vector2 v3, Color color) { + if (rlCheckBufferLimit(4)) rlglDraw(); + #if defined(SUPPORT_QUADS_DRAW_MODE) rlEnableTexture(GetShapesTexture().id); @@ -1214,6 +1216,8 @@ void DrawTriangle(Vector2 v1, Vector2 v2, Vector2 v3, Color color) // Draw a triangle using lines void DrawTriangleLines(Vector2 v1, Vector2 v2, Vector2 v3, Color color) { + if (rlCheckBufferLimit(6)) rlglDraw(); + rlBegin(RL_LINES); rlColor4ub(color.r, color.g, color.b, color.a); rlVertex2f(v1.x, v1.y); @@ -1258,6 +1262,36 @@ void DrawTriangleFan(Vector2 *points, int pointsCount, Color color) } } +// Draw a triangle strip defined by points +// NOTE: Every new point connects with previous two +void DrawTriangleStrip(Vector2 *points, int pointsCount, Color color) +{ + if (pointsCount >= 3) + { + if (rlCheckBufferLimit(pointsCount)) rlglDraw(); + + rlBegin(RL_TRIANGLES); + rlColor4ub(color.r, color.g, color.b, color.a); + + for (int i = 2; i < pointsCount; i++) + { + if ((i%2) == 0) + { + rlVertex2f(points[i].x, points[i].y); + rlVertex2f(points[i - 2].x, points[i - 2].y); + rlVertex2f(points[i - 1].x, points[i - 1].y); + } + else + { + rlVertex2f(points[i].x, points[i].y); + rlVertex2f(points[i - 1].x, points[i - 1].y); + rlVertex2f(points[i - 2].x, points[i - 2].y); + } + } + rlEnd(); + } +} + // Draw a regular polygon of n sides (Vector version) void DrawPoly(Vector2 center, int sides, float radius, float rotation, Color color) { |
