aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorraysan5 <raysan5@gmail.com>2019-04-28 14:45:46 +0200
committerraysan5 <raysan5@gmail.com>2019-04-28 14:45:46 +0200
commit604a8c0b78b6f51abcce61aa0c3db25412acafa7 (patch)
treef03efd4f077a145c24dd2787cb41ff76a59020dd /src
parentf70a640b2db343d48e465013cacb304f8dabebcb (diff)
downloadraylib-604a8c0b78b6f51abcce61aa0c3db25412acafa7.tar.gz
raylib-604a8c0b78b6f51abcce61aa0c3db25412acafa7.zip
WARNING: Functions renamed
Two functions have been renamed for coherence; previous naming was confusing for several users: - DrawPolyEx() ---> DrawTriangleFan() - DrawPolyExLines() ---> DrawLineStrip()
Diffstat (limited to 'src')
-rw-r--r--src/raylib.h4
-rw-r--r--src/shapes.c99
2 files changed, 52 insertions, 51 deletions
diff --git a/src/raylib.h b/src/raylib.h
index 43260e06..c1cebdc8 100644
--- a/src/raylib.h
+++ b/src/raylib.h
@@ -1058,6 +1058,7 @@ RLAPI void DrawLine(int startPosX, int startPosY, int endPosX, int endPosY, Colo
RLAPI void DrawLineV(Vector2 startPos, Vector2 endPos, Color color); // Draw a line (Vector version)
RLAPI void DrawLineEx(Vector2 startPos, Vector2 endPos, float thick, Color color); // Draw a line defining thickness
RLAPI void DrawLineBezier(Vector2 startPos, Vector2 endPos, float thick, Color color); // Draw a line using cubic-bezier curves in-out
+RLAPI void DrawLineStrip(Vector2 *points, int numPoints, Color color); // Draw lines sequence
RLAPI void DrawCircle(int centerX, int centerY, float radius, Color color); // Draw a color-filled circle
RLAPI void DrawCircleSector(Vector2 center, float radius, int startAngle, int endAngle, int segments, Color color); // Draw a piece of a circle
RLAPI void DrawCircleSectorLines(Vector2 center, float radius, int startAngle, int endAngle, int segments, Color color); // Draw circle sector outline
@@ -1079,9 +1080,8 @@ RLAPI void DrawRectangleRounded(Rectangle rec, float roundness, int segments, Co
RLAPI void DrawRectangleRoundedLines(Rectangle rec, float roundness, int segments, int lineThick, Color color); // Draw rectangle with rounded edges outline
RLAPI void DrawTriangle(Vector2 v1, Vector2 v2, Vector2 v3, Color color); // Draw a color-filled triangle
RLAPI void DrawTriangleLines(Vector2 v1, Vector2 v2, Vector2 v3, Color color); // Draw triangle outline
+RLAPI void DrawTriangleFan(Vector2 *points, int numPoints, Color color); // Draw a triangle fan defined by points
RLAPI void DrawPoly(Vector2 center, int sides, float radius, float rotation, Color color); // Draw a regular polygon (Vector version)
-RLAPI void DrawPolyEx(Vector2 *points, int numPoints, Color color); // Draw a closed polygon defined by points
-RLAPI void DrawPolyExLines(Vector2 *points, int numPoints, Color color); // Draw polygon lines
RLAPI void SetShapesTexture(Texture2D texture, Rectangle source); // Define default texture used to draw shapes
diff --git a/src/shapes.c b/src/shapes.c
index ecef287c..93b332f5 100644
--- a/src/shapes.c
+++ b/src/shapes.c
@@ -176,6 +176,25 @@ void DrawLineBezier(Vector2 startPos, Vector2 endPos, float thick, Color color)
}
}
+// Draw lines sequence
+void DrawLineStrip(Vector2 *points, int pointsCount, Color color)
+{
+ if (pointsCount >= 2)
+ {
+ if (rlCheckBufferLimit(pointsCount)) rlglDraw();
+
+ rlBegin(RL_LINES);
+ rlColor4ub(color.r, color.g, color.b, color.a);
+
+ for (int i = 0; i < pointsCount - 1; i++)
+ {
+ rlVertex2f(points[i].x, points[i].y);
+ rlVertex2f(points[i + 1].x, points[i + 1].y);
+ }
+ rlEnd();
+ }
+}
+
// Draw a color-filled circle
void DrawCircle(int centerX, int centerY, float radius, Color color)
{
@@ -1208,6 +1227,37 @@ void DrawTriangleLines(Vector2 v1, Vector2 v2, Vector2 v3, Color color)
rlEnd();
}
+// Draw a triangle fan defined by points
+// NOTE: First point provided is shared by all triangles
+void DrawTriangleFan(Vector2 *points, int pointsCount, Color color)
+{
+ if (pointsCount >= 3)
+ {
+ if (rlCheckBufferLimit((pointsCount - 2)*4)) rlglDraw();
+
+ rlEnableTexture(GetShapesTexture().id);
+ rlBegin(RL_QUADS);
+ rlColor4ub(color.r, color.g, color.b, color.a);
+
+ for (int i = 1; i < pointsCount - 1; i++)
+ {
+ rlTexCoord2f(recTexShapes.x/texShapes.width, recTexShapes.y/texShapes.height);
+ rlVertex2f(points[0].x, points[0].y);
+
+ rlTexCoord2f(recTexShapes.x/texShapes.width, (recTexShapes.y + recTexShapes.height)/texShapes.height);
+ rlVertex2f(points[i].x, points[i].y);
+
+ rlTexCoord2f((recTexShapes.x + recTexShapes.width)/texShapes.width, (recTexShapes.y + recTexShapes.height)/texShapes.height);
+ rlVertex2f(points[i + 1].x, points[i + 1].y);
+
+ rlTexCoord2f((recTexShapes.x + recTexShapes.width)/texShapes.width, recTexShapes.y/texShapes.height);
+ rlVertex2f(points[i + 1].x, points[i + 1].y);
+ }
+ rlEnd();
+ rlDisableTexture();
+ }
+}
+
// Draw a regular polygon of n sides (Vector version)
void DrawPoly(Vector2 center, int sides, float radius, float rotation, Color color)
{
@@ -1256,55 +1306,6 @@ void DrawPoly(Vector2 center, int sides, float radius, float rotation, Color col
rlPopMatrix();
}
-// Draw a closed polygon defined by points
-void DrawPolyEx(Vector2 *points, int pointsCount, Color color)
-{
- if (pointsCount >= 3)
- {
- if (rlCheckBufferLimit((pointsCount - 2)*4)) rlglDraw();
-
- rlEnableTexture(GetShapesTexture().id);
- rlBegin(RL_QUADS);
- rlColor4ub(color.r, color.g, color.b, color.a);
-
- for (int i = 1; i < pointsCount - 1; i++)
- {
- rlTexCoord2f(recTexShapes.x/texShapes.width, recTexShapes.y/texShapes.height);
- rlVertex2f(points[0].x, points[0].y);
-
- rlTexCoord2f(recTexShapes.x/texShapes.width, (recTexShapes.y + recTexShapes.height)/texShapes.height);
- rlVertex2f(points[i].x, points[i].y);
-
- rlTexCoord2f((recTexShapes.x + recTexShapes.width)/texShapes.width, (recTexShapes.y + recTexShapes.height)/texShapes.height);
- rlVertex2f(points[i + 1].x, points[i + 1].y);
-
- rlTexCoord2f((recTexShapes.x + recTexShapes.width)/texShapes.width, recTexShapes.y/texShapes.height);
- rlVertex2f(points[i + 1].x, points[i + 1].y);
- }
- rlEnd();
- rlDisableTexture();
- }
-}
-
-// Draw polygon using lines
-void DrawPolyExLines(Vector2 *points, int pointsCount, Color color)
-{
- if (pointsCount >= 2)
- {
- if (rlCheckBufferLimit(pointsCount)) rlglDraw();
-
- rlBegin(RL_LINES);
- rlColor4ub(color.r, color.g, color.b, color.a);
-
- for (int i = 0; i < pointsCount - 1; i++)
- {
- rlVertex2f(points[i].x, points[i].y);
- rlVertex2f(points[i + 1].x, points[i + 1].y);
- }
- rlEnd();
- }
-}
-
// Define default texture used to draw shapes
void SetShapesTexture(Texture2D texture, Rectangle source)
{