Review DrawPolyEx()
Also reviewed rlCheckBufferLimit()
This commit is contained in:
parent
4ec4dc691f
commit
92f68ac6be
3 changed files with 11 additions and 28 deletions
|
@ -435,7 +435,7 @@ void rlglClose(void); // De-inititialize rlgl (buffers
|
||||||
void rlglDraw(void); // Update and draw default internal buffers
|
void rlglDraw(void); // Update and draw default internal buffers
|
||||||
|
|
||||||
int rlGetVersion(void); // Returns current OpenGL version
|
int rlGetVersion(void); // Returns current OpenGL version
|
||||||
bool rlCheckBufferLimit(int type, int vCount); // Check internal buffer overflow for a given number of vertex
|
bool rlCheckBufferLimit(int vCount); // Check internal buffer overflow for a given number of vertex
|
||||||
void rlSetDebugMarker(const char *text); // Set debug marker for analysis
|
void rlSetDebugMarker(const char *text); // Set debug marker for analysis
|
||||||
void rlLoadExtensions(void *loader); // Load OpenGL extensions
|
void rlLoadExtensions(void *loader); // Load OpenGL extensions
|
||||||
Vector3 rlUnproject(Vector3 source, Matrix proj, Matrix view); // Get world coordinates from screen coordinates
|
Vector3 rlUnproject(Vector3 source, Matrix proj, Matrix view); // Get world coordinates from screen coordinates
|
||||||
|
@ -1738,7 +1738,7 @@ int rlGetVersion(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check internal buffer overflow for a given number of vertex
|
// Check internal buffer overflow for a given number of vertex
|
||||||
bool rlCheckBufferLimit(int type, int vCount)
|
bool rlCheckBufferLimit(int vCount)
|
||||||
{
|
{
|
||||||
bool overflow = false;
|
bool overflow = false;
|
||||||
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
|
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
|
||||||
|
|
31
src/shapes.c
31
src/shapes.c
|
@ -186,7 +186,7 @@ void DrawCircle(int centerX, int centerY, float radius, Color color)
|
||||||
// NOTE: Gradient goes from center (color1) to border (color2)
|
// NOTE: Gradient goes from center (color1) to border (color2)
|
||||||
void DrawCircleGradient(int centerX, int centerY, float radius, Color color1, Color color2)
|
void DrawCircleGradient(int centerX, int centerY, float radius, Color color1, Color color2)
|
||||||
{
|
{
|
||||||
if (rlCheckBufferLimit(RL_TRIANGLES, 3*36)) rlglDraw();
|
if (rlCheckBufferLimit(3*36)) rlglDraw();
|
||||||
|
|
||||||
rlBegin(RL_TRIANGLES);
|
rlBegin(RL_TRIANGLES);
|
||||||
for (int i = 0; i < 360; i += 10)
|
for (int i = 0; i < 360; i += 10)
|
||||||
|
@ -206,7 +206,7 @@ void DrawCircleGradient(int centerX, int centerY, float radius, Color color1, Co
|
||||||
void DrawCircleV(Vector2 center, float radius, Color color)
|
void DrawCircleV(Vector2 center, float radius, Color color)
|
||||||
{
|
{
|
||||||
#if defined(SUPPORT_QUADS_DRAW_MODE)
|
#if defined(SUPPORT_QUADS_DRAW_MODE)
|
||||||
if (rlCheckBufferLimit(RL_QUADS, 4*(36/2))) rlglDraw();
|
if (rlCheckBufferLimit(4*(36/2))) rlglDraw();
|
||||||
|
|
||||||
rlEnableTexture(GetShapesTexture().id);
|
rlEnableTexture(GetShapesTexture().id);
|
||||||
|
|
||||||
|
@ -231,7 +231,7 @@ void DrawCircleV(Vector2 center, float radius, Color color)
|
||||||
|
|
||||||
rlDisableTexture();
|
rlDisableTexture();
|
||||||
#else
|
#else
|
||||||
if (rlCheckBufferLimit(RL_TRIANGLES, 3*(36/2))) rlglDraw();
|
if (rlCheckBufferLimit(3*(36/2))) rlglDraw();
|
||||||
|
|
||||||
rlBegin(RL_TRIANGLES);
|
rlBegin(RL_TRIANGLES);
|
||||||
for (int i = 0; i < 360; i += 10)
|
for (int i = 0; i < 360; i += 10)
|
||||||
|
@ -249,7 +249,7 @@ void DrawCircleV(Vector2 center, float radius, Color color)
|
||||||
// Draw circle outline
|
// Draw circle outline
|
||||||
void DrawCircleLines(int centerX, int centerY, float radius, Color color)
|
void DrawCircleLines(int centerX, int centerY, float radius, Color color)
|
||||||
{
|
{
|
||||||
if (rlCheckBufferLimit(RL_LINES, 2*36)) rlglDraw();
|
if (rlCheckBufferLimit(2*36)) rlglDraw();
|
||||||
|
|
||||||
rlBegin(RL_LINES);
|
rlBegin(RL_LINES);
|
||||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
rlColor4ub(color.r, color.g, color.b, color.a);
|
||||||
|
@ -440,7 +440,7 @@ void DrawPoly(Vector2 center, int sides, float radius, float rotation, Color col
|
||||||
{
|
{
|
||||||
if (sides < 3) sides = 3;
|
if (sides < 3) sides = 3;
|
||||||
|
|
||||||
if (rlCheckBufferLimit(RL_QUADS, 4*(360/sides))) rlglDraw();
|
if (rlCheckBufferLimit(4*(360/sides))) rlglDraw();
|
||||||
|
|
||||||
rlPushMatrix();
|
rlPushMatrix();
|
||||||
rlTranslatef(center.x, center.y, 0.0);
|
rlTranslatef(center.x, center.y, 0.0);
|
||||||
|
@ -488,24 +488,8 @@ void DrawPolyEx(Vector2 *points, int pointsCount, Color color)
|
||||||
{
|
{
|
||||||
if (pointsCount >= 3)
|
if (pointsCount >= 3)
|
||||||
{
|
{
|
||||||
if (rlCheckBufferLimit(RL_QUADS, pointsCount)) rlglDraw();
|
if (rlCheckBufferLimit(pointsCount)) rlglDraw();
|
||||||
|
|
||||||
#if defined(SUPPORT_QUADS_DRAW_MODE)
|
|
||||||
rlEnableTexture(GetShapesTexture().id);
|
|
||||||
|
|
||||||
rlBegin(RL_QUADS);
|
|
||||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
|
||||||
|
|
||||||
for (int i = 1; i < pointsCount - 1; i++)
|
|
||||||
{
|
|
||||||
rlVertex2f(points[0].x, points[0].y);
|
|
||||||
rlVertex2f(points[i].x, points[i].y);
|
|
||||||
rlVertex2f(points[i].x, points[i].y);
|
|
||||||
rlVertex2f(points[i + 1].x, points[i + 1].y);
|
|
||||||
}
|
|
||||||
rlEnd();
|
|
||||||
rlDisableTexture();
|
|
||||||
#else
|
|
||||||
rlBegin(RL_TRIANGLES);
|
rlBegin(RL_TRIANGLES);
|
||||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
rlColor4ub(color.r, color.g, color.b, color.a);
|
||||||
|
|
||||||
|
@ -516,7 +500,6 @@ void DrawPolyEx(Vector2 *points, int pointsCount, Color color)
|
||||||
rlVertex2f(points[i + 1].x, points[i + 1].y);
|
rlVertex2f(points[i + 1].x, points[i + 1].y);
|
||||||
}
|
}
|
||||||
rlEnd();
|
rlEnd();
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -525,7 +508,7 @@ void DrawPolyExLines(Vector2 *points, int pointsCount, Color color)
|
||||||
{
|
{
|
||||||
if (pointsCount >= 2)
|
if (pointsCount >= 2)
|
||||||
{
|
{
|
||||||
if (rlCheckBufferLimit(RL_LINES, pointsCount)) rlglDraw();
|
if (rlCheckBufferLimit(pointsCount)) rlglDraw();
|
||||||
|
|
||||||
rlBegin(RL_LINES);
|
rlBegin(RL_LINES);
|
||||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
rlColor4ub(color.r, color.g, color.b, color.a);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue