Merge branch 'raysan5:master' into master

This commit is contained in:
Luiz Pestana 2022-09-08 14:30:25 -03:00 committed by GitHub
commit b2a6e8e827
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 371 additions and 485 deletions

View File

@ -18,7 +18,7 @@
#include <stdio.h> // Required for: fopen(), fclose(), fputc(), fwrite(), printf(), fprintf(), funopen() #include <stdio.h> // Required for: fopen(), fclose(), fputc(), fwrite(), printf(), fprintf(), funopen()
#include <time.h> // Required for: time_t, tm, time(), localtime(), strftime() #include <time.h> // Required for: time_t, tm, time(), localtime(), strftime()
// Custom logging funtion // Custom logging function
void CustomLog(int msgType, const char *text, va_list args) void CustomLog(int msgType, const char *text, va_list args)
{ {
char timeStr[64] = { 0 }; char timeStr[64] = { 0 };

View File

@ -2,7 +2,7 @@
* *
* raylib [shapes] example - Draw basic shapes 2d (rectangle, circle, line...) * raylib [shapes] example - Draw basic shapes 2d (rectangle, circle, line...)
* *
* Example originally created with raylib 1.0, last time updated with raylib 4.0 * Example originally created with raylib 1.0, last time updated with raylib 4.2
* *
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified, * Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software * BSD-like license that allows static linking with closed source software
@ -25,6 +25,8 @@ int main(void)
InitWindow(screenWidth, screenHeight, "raylib [shapes] example - basic shapes drawing"); InitWindow(screenWidth, screenHeight, "raylib [shapes] example - basic shapes drawing");
float rotation = 0.0f;
SetTargetFPS(60); // Set our game to run at 60 frames-per-second SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
@ -33,7 +35,7 @@ int main(void)
{ {
// Update // Update
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// TODO: Update your variables here rotation += 0.2f;
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Draw // Draw
@ -55,17 +57,18 @@ int main(void)
DrawRectangleLines(screenWidth/4*2 - 40, 320, 80, 60, ORANGE); // NOTE: Uses QUADS internally, not lines DrawRectangleLines(screenWidth/4*2 - 40, 320, 80, 60, ORANGE); // NOTE: Uses QUADS internally, not lines
// Triangle shapes and lines // Triangle shapes and lines
DrawTriangle((Vector2){screenWidth/4.0f *3.0f, 80.0f}, DrawTriangle((Vector2){ screenWidth/4.0f *3.0f, 80.0f },
(Vector2){screenWidth/4.0f *3.0f - 60.0f, 150.0f}, (Vector2){ screenWidth/4.0f *3.0f - 60.0f, 150.0f },
(Vector2){screenWidth/4.0f *3.0f + 60.0f, 150.0f}, VIOLET); (Vector2){ screenWidth/4.0f *3.0f + 60.0f, 150.0f }, VIOLET);
DrawTriangleLines((Vector2){screenWidth/4.0f*3.0f, 160.0f}, DrawTriangleLines((Vector2){ screenWidth/4.0f*3.0f, 160.0f },
(Vector2){screenWidth/4.0f*3.0f - 20.0f, 230.0f}, (Vector2){ screenWidth/4.0f*3.0f - 20.0f, 230.0f },
(Vector2){screenWidth/4.0f*3.0f + 20.0f, 230.0f}, DARKBLUE); (Vector2){ screenWidth/4.0f*3.0f + 20.0f, 230.0f }, DARKBLUE);
// Polygon shapes and lines // Polygon shapes and lines
DrawPoly((Vector2){screenWidth/4.0f*3, 320}, 6, 80, 0, BROWN); DrawPoly((Vector2){ screenWidth/4.0f*3, 330 }, 6, 80, rotation, BROWN);
DrawPolyLinesEx((Vector2){screenWidth/4.0f*3, 320}, 6, 80, 0, 6, BEIGE); DrawPolyLines((Vector2){ screenWidth/4.0f*3, 330 }, 6, 90, rotation, BROWN);
DrawPolyLinesEx((Vector2){ screenWidth/4.0f*3, 330 }, 6, 85, rotation, 6, BEIGE);
// NOTE: We draw all LINES based shapes together to optimize internal drawing, // NOTE: We draw all LINES based shapes together to optimize internal drawing,
// this way, all LINES are rendered in a single draw pass // this way, all LINES are rendered in a single draw pass

View File

@ -1039,8 +1039,8 @@ RLAPI void SetConfigFlags(unsigned int flags); // Setup init
RLAPI void TraceLog(int logLevel, const char *text, ...); // Show trace log messages (LOG_DEBUG, LOG_INFO, LOG_WARNING, LOG_ERROR...) RLAPI void TraceLog(int logLevel, const char *text, ...); // Show trace log messages (LOG_DEBUG, LOG_INFO, LOG_WARNING, LOG_ERROR...)
RLAPI void SetTraceLogLevel(int logLevel); // Set the current threshold (minimum) log level RLAPI void SetTraceLogLevel(int logLevel); // Set the current threshold (minimum) log level
RLAPI void *MemAlloc(int size); // Internal memory allocator RLAPI void *MemAlloc(unsigned int size); // Internal memory allocator
RLAPI void *MemRealloc(void *ptr, int size); // Internal memory reallocator RLAPI void *MemRealloc(void *ptr, unsigned int size); // Internal memory reallocator
RLAPI void MemFree(void *ptr); // Internal memory free RLAPI void MemFree(void *ptr); // Internal memory free
RLAPI void OpenURL(const char *url); // Open URL with default system browser (if available) RLAPI void OpenURL(const char *url); // Open URL with default system browser (if available)

View File

@ -2376,7 +2376,7 @@ VrStereoConfig LoadVrStereoConfig(VrDeviceInfo device)
{ {
VrStereoConfig config = { 0 }; VrStereoConfig config = { 0 };
if ((rlGetVersion() == OPENGL_33) || (rlGetVersion() == OPENGL_ES_20)) if ((rlGetVersion() == RL_OPENGL_33) || (rlGetVersion() == RL_OPENGL_ES_20))
{ {
// Compute aspect ratio // Compute aspect ratio
float aspect = ((float)device.hResolution*0.5f)/(float)device.vResolution; float aspect = ((float)device.hResolution*0.5f)/(float)device.vResolution;
@ -4043,12 +4043,12 @@ static bool InitGraphicsDevice(int width, int height)
// For example, if using OpenGL 1.1, driver can provide a 4.3 context forward compatible. // For example, if using OpenGL 1.1, driver can provide a 4.3 context forward compatible.
// Check selection OpenGL version // Check selection OpenGL version
if (rlGetVersion() == OPENGL_21) if (rlGetVersion() == RL_OPENGL_21)
{ {
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2); // Choose OpenGL major version (just hint) glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2); // Choose OpenGL major version (just hint)
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1); // Choose OpenGL minor version (just hint) glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1); // Choose OpenGL minor version (just hint)
} }
else if (rlGetVersion() == OPENGL_33) else if (rlGetVersion() == RL_OPENGL_33)
{ {
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); // Choose OpenGL major version (just hint) glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); // Choose OpenGL major version (just hint)
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); // Choose OpenGL minor version (just hint) glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); // Choose OpenGL minor version (just hint)
@ -4061,7 +4061,7 @@ static bool InitGraphicsDevice(int width, int height)
#endif #endif
//glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GLFW_TRUE); // Request OpenGL DEBUG context //glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GLFW_TRUE); // Request OpenGL DEBUG context
} }
else if (rlGetVersion() == OPENGL_43) else if (rlGetVersion() == RL_OPENGL_43)
{ {
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4); // Choose OpenGL major version (just hint) glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4); // Choose OpenGL major version (just hint)
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); // Choose OpenGL minor version (just hint) glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); // Choose OpenGL minor version (just hint)
@ -4071,7 +4071,7 @@ static bool InitGraphicsDevice(int width, int height)
glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GLFW_TRUE); // Enable OpenGL Debug Context glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GLFW_TRUE); // Enable OpenGL Debug Context
#endif #endif
} }
else if (rlGetVersion() == OPENGL_ES_20) // Request OpenGL ES 2.0 context else if (rlGetVersion() == RL_OPENGL_ES_20) // Request OpenGL ES 2.0 context
{ {
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2); glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);

View File

@ -1,6 +1,6 @@
/********************************************************************************************** /**********************************************************************************************
* *
* rlgl v4.0 - A multi-OpenGL abstraction layer with an immediate-mode style API * rlgl v4.2 - A multi-OpenGL abstraction layer with an immediate-mode style API
* *
* An abstraction layer for multiple OpenGL versions (1.1, 2.1, 3.3 Core, 4.3 Core, ES 2.0) * An abstraction layer for multiple OpenGL versions (1.1, 2.1, 3.3 Core, 4.3 Core, ES 2.0)
* that provides a pseudo-OpenGL 1.1 immediate-mode style API (rlVertex, rlTranslate, rlRotate...) * that provides a pseudo-OpenGL 1.1 immediate-mode style API (rlVertex, rlTranslate, rlRotate...)
@ -107,7 +107,7 @@
#ifndef RLGL_H #ifndef RLGL_H
#define RLGL_H #define RLGL_H
#define RLGL_VERSION "4.0" #define RLGL_VERSION "4.2"
// Function specifiers in case library is build/used as a shared library (Windows) // Function specifiers in case library is build/used as a shared library (Windows)
// NOTE: Microsoft specifiers to tell compiler that symbols are imported/exported from a .dll // NOTE: Microsoft specifiers to tell compiler that symbols are imported/exported from a .dll
@ -243,7 +243,7 @@
#define RL_TEXTURE_FILTER_LINEAR_MIP_NEAREST 0x2701 // GL_LINEAR_MIPMAP_NEAREST #define RL_TEXTURE_FILTER_LINEAR_MIP_NEAREST 0x2701 // GL_LINEAR_MIPMAP_NEAREST
#define RL_TEXTURE_FILTER_MIP_LINEAR 0x2703 // GL_LINEAR_MIPMAP_LINEAR #define RL_TEXTURE_FILTER_MIP_LINEAR 0x2703 // GL_LINEAR_MIPMAP_LINEAR
#define RL_TEXTURE_FILTER_ANISOTROPIC 0x3000 // Anisotropic filter (custom identifier) #define RL_TEXTURE_FILTER_ANISOTROPIC 0x3000 // Anisotropic filter (custom identifier)
#define RL_TEXTURE_MIPMAP_BIAS_RATIO 0x4000 // Texture mipmap bias (percentage ratio) #define RL_TEXTURE_MIPMAP_BIAS_RATIO 0x4000 // Texture mipmap bias, percentage ratio (custom identifier)
#define RL_TEXTURE_WRAP_REPEAT 0x2901 // GL_REPEAT #define RL_TEXTURE_WRAP_REPEAT 0x2901 // GL_REPEAT
#define RL_TEXTURE_WRAP_CLAMP 0x812F // GL_CLAMP_TO_EDGE #define RL_TEXTURE_WRAP_CLAMP 0x812F // GL_CLAMP_TO_EDGE
@ -283,37 +283,23 @@
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Types and Structures Definition // Types and Structures Definition
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
typedef enum { #if (defined(__STDC__) && __STDC_VERSION__ >= 199901L) || (defined(_MSC_VER) && _MSC_VER >= 1800)
OPENGL_11 = 1, #include <stdbool.h>
OPENGL_21, #elif !defined(__cplusplus) && !defined(bool) && !defined(RL_BOOL_TYPE)
OPENGL_33, // Boolean type
OPENGL_43, typedef enum bool { false = 0, true = !false } bool;
OPENGL_ES_20 #endif
} rlGlVersion;
typedef enum { #if !defined(RL_MATRIX_TYPE)
RL_ATTACHMENT_COLOR_CHANNEL0 = 0, // Matrix, 4x4 components, column major, OpenGL style, right handed
RL_ATTACHMENT_COLOR_CHANNEL1, typedef struct Matrix {
RL_ATTACHMENT_COLOR_CHANNEL2, float m0, m4, m8, m12; // Matrix first row (4 components)
RL_ATTACHMENT_COLOR_CHANNEL3, float m1, m5, m9, m13; // Matrix second row (4 components)
RL_ATTACHMENT_COLOR_CHANNEL4, float m2, m6, m10, m14; // Matrix third row (4 components)
RL_ATTACHMENT_COLOR_CHANNEL5, float m3, m7, m11, m15; // Matrix fourth row (4 components)
RL_ATTACHMENT_COLOR_CHANNEL6, } Matrix;
RL_ATTACHMENT_COLOR_CHANNEL7, #define RL_MATRIX_TYPE
RL_ATTACHMENT_DEPTH = 100, #endif
RL_ATTACHMENT_STENCIL = 200,
} rlFramebufferAttachType;
typedef enum {
RL_ATTACHMENT_CUBEMAP_POSITIVE_X = 0,
RL_ATTACHMENT_CUBEMAP_NEGATIVE_X,
RL_ATTACHMENT_CUBEMAP_POSITIVE_Y,
RL_ATTACHMENT_CUBEMAP_NEGATIVE_Y,
RL_ATTACHMENT_CUBEMAP_POSITIVE_Z,
RL_ATTACHMENT_CUBEMAP_NEGATIVE_Z,
RL_ATTACHMENT_TEXTURE2D = 100,
RL_ATTACHMENT_RENDERBUFFER = 200,
} rlFramebufferAttachTextureType;
// Dynamic vertex buffers (position + texcoords + colors + indices arrays) // Dynamic vertex buffers (position + texcoords + colors + indices arrays)
typedef struct rlVertexBuffer { typedef struct rlVertexBuffer {
@ -359,23 +345,14 @@ typedef struct rlRenderBatch {
float currentDepth; // Current depth value for next draw float currentDepth; // Current depth value for next draw
} rlRenderBatch; } rlRenderBatch;
#if (defined(__STDC__) && __STDC_VERSION__ >= 199901L) || (defined(_MSC_VER) && _MSC_VER >= 1800) // OpenGL version
#include <stdbool.h> typedef enum {
#elif !defined(__cplusplus) && !defined(bool) && !defined(RL_BOOL_TYPE) RL_OPENGL_11 = 1, // OpenGL 1.1
// Boolean type RL_OPENGL_21, // OpenGL 2.1 (GLSL 120)
typedef enum bool { false = 0, true = !false } bool; RL_OPENGL_33, // OpenGL 3.3 (GLSL 330)
#endif RL_OPENGL_43, // OpenGL 4.3 (using GLSL 330)
RL_OPENGL_ES_20 // OpenGL ES 2.0 (GLSL 100)
#if !defined(RL_MATRIX_TYPE) } rlGlVersion;
// Matrix, 4x4 components, column major, OpenGL style, right handed
typedef struct Matrix {
float m0, m4, m8, m12; // Matrix first row (4 components)
float m1, m5, m9, m13; // Matrix second row (4 components)
float m2, m6, m10, m14; // Matrix third row (4 components)
float m3, m7, m11, m15; // Matrix fourth row (4 components)
} Matrix;
#define RL_MATRIX_TYPE
#endif
// Trace log level // Trace log level
// NOTE: Organized by priority level // NOTE: Organized by priority level
@ -390,7 +367,8 @@ typedef enum {
RL_LOG_NONE // Disable logging RL_LOG_NONE // Disable logging
} rlTraceLogLevel; } rlTraceLogLevel;
// Texture formats (support depends on OpenGL version) // Texture pixel formats
// NOTE: Support depends on OpenGL version
typedef enum { typedef enum {
RL_PIXELFORMAT_UNCOMPRESSED_GRAYSCALE = 1, // 8 bit per pixel (no alpha) RL_PIXELFORMAT_UNCOMPRESSED_GRAYSCALE = 1, // 8 bit per pixel (no alpha)
RL_PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA, // 8*2 bpp (2 channels) RL_PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA, // 8*2 bpp (2 channels)
@ -492,6 +470,33 @@ typedef enum {
RL_SHADER_ATTRIB_VEC4 // Shader attribute type: vec4 (4 float) RL_SHADER_ATTRIB_VEC4 // Shader attribute type: vec4 (4 float)
} rlShaderAttributeDataType; } rlShaderAttributeDataType;
// Framebuffer attachment type
// NOTE: By default up to 8 color channels defined but it can be more
typedef enum {
RL_ATTACHMENT_COLOR_CHANNEL0 = 0, // Framebuffer attachmment type: color 0
RL_ATTACHMENT_COLOR_CHANNEL1, // Framebuffer attachmment type: color 1
RL_ATTACHMENT_COLOR_CHANNEL2, // Framebuffer attachmment type: color 2
RL_ATTACHMENT_COLOR_CHANNEL3, // Framebuffer attachmment type: color 3
RL_ATTACHMENT_COLOR_CHANNEL4, // Framebuffer attachmment type: color 4
RL_ATTACHMENT_COLOR_CHANNEL5, // Framebuffer attachmment type: color 5
RL_ATTACHMENT_COLOR_CHANNEL6, // Framebuffer attachmment type: color 6
RL_ATTACHMENT_COLOR_CHANNEL7, // Framebuffer attachmment type: color 7
RL_ATTACHMENT_DEPTH = 100, // Framebuffer attachmment type: depth
RL_ATTACHMENT_STENCIL = 200, // Framebuffer attachmment type: stencil
} rlFramebufferAttachType;
// Framebuffer texture attachment type
typedef enum {
RL_ATTACHMENT_CUBEMAP_POSITIVE_X = 0, // Framebuffer texture attachment type: cubemap, +X side
RL_ATTACHMENT_CUBEMAP_NEGATIVE_X, // Framebuffer texture attachment type: cubemap, -X side
RL_ATTACHMENT_CUBEMAP_POSITIVE_Y, // Framebuffer texture attachment type: cubemap, +Y side
RL_ATTACHMENT_CUBEMAP_NEGATIVE_Y, // Framebuffer texture attachment type: cubemap, -Y side
RL_ATTACHMENT_CUBEMAP_POSITIVE_Z, // Framebuffer texture attachment type: cubemap, +Z side
RL_ATTACHMENT_CUBEMAP_NEGATIVE_Z, // Framebuffer texture attachment type: cubemap, -Z side
RL_ATTACHMENT_TEXTURE2D = 100, // Framebuffer texture attachment type: texture2d
RL_ATTACHMENT_RENDERBUFFER = 200, // Framebuffer texture attachment type: renderbuffer
} rlFramebufferAttachTextureType;
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Functions Declaration - Matrix operations // Functions Declaration - Matrix operations
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
@ -617,6 +622,7 @@ RLAPI void rlDrawRenderBatch(rlRenderBatch *batch); // D
RLAPI void rlSetRenderBatchActive(rlRenderBatch *batch); // Set the active render batch for rlgl (NULL for default internal) RLAPI void rlSetRenderBatchActive(rlRenderBatch *batch); // Set the active render batch for rlgl (NULL for default internal)
RLAPI void rlDrawRenderBatchActive(void); // Update and draw internal render batch RLAPI void rlDrawRenderBatchActive(void); // Update and draw internal render batch
RLAPI bool rlCheckRenderBatchLimit(int vCount); // Check internal buffer overflow for a given number of vertex RLAPI bool rlCheckRenderBatchLimit(int vCount); // Check internal buffer overflow for a given number of vertex
RLAPI void rlSetTexture(unsigned int id); // Set current texture for render batch and check buffers limits RLAPI void rlSetTexture(unsigned int id); // Set current texture for render batch and check buffers limits
//------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------
@ -1307,17 +1313,6 @@ void rlEnd(void)
// as well as depth buffer bit-depth (16bit or 24bit or 32bit) // as well as depth buffer bit-depth (16bit or 24bit or 32bit)
// Correct increment formula would be: depthInc = (zfar - znear)/pow(2, bits) // Correct increment formula would be: depthInc = (zfar - znear)/pow(2, bits)
RLGL.currentBatch->currentDepth += (1.0f/20000.0f); RLGL.currentBatch->currentDepth += (1.0f/20000.0f);
// Verify internal buffers limits
// NOTE: This check is combined with usage of rlCheckRenderBatchLimit()
if (RLGL.State.vertexCounter >= (RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].elementCount*4 - 4))
{
// WARNING: If we are between rlPushMatrix() and rlPopMatrix() and we need to force a rlDrawRenderBatch(),
// we need to call rlPopMatrix() before to recover *RLGL.State.currentMatrix (RLGL.State.modelview) for the next forced draw call!
// If we have multiple matrix pushed, it will require "RLGL.State.stackCounter" pops before launching the draw
for (int i = RLGL.State.stackCounter; i >= 0; i--) rlPopMatrix();
rlDrawRenderBatch(RLGL.currentBatch);
}
} }
// Define one vertex (position) // Define one vertex (position)
@ -1336,9 +1331,31 @@ void rlVertex3f(float x, float y, float z)
tz = RLGL.State.transform.m2*x + RLGL.State.transform.m6*y + RLGL.State.transform.m10*z + RLGL.State.transform.m14; tz = RLGL.State.transform.m2*x + RLGL.State.transform.m6*y + RLGL.State.transform.m10*z + RLGL.State.transform.m14;
} }
// Verify that current vertex buffer elements limit has not been reached // WARNING: We can't break primitives when launching a new batch.
if (RLGL.State.vertexCounter < (RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].elementCount*4)) // RL_LINES comes in pairs, RL_TRIANGLES come in groups of 3 vertices and RL_QUADS come in groups of 4 vertices.
// We must check current draw.mode when a new vertex is required and finish the batch only if the draw.mode draw.vertexCount is %2, %3 or %4
if (RLGL.State.vertexCounter > (RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].elementCount*4 - 4))
{ {
if ((RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].mode == RL_LINES) &&
(RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount%2 == 0))
{
// Reached the maximum number of vertices for RL_LINES drawing
// Launch a draw call but keep current state for next vertices comming
// NOTE: We add +1 vertex to the check for security
rlCheckRenderBatchLimit(2 + 1);
}
else if ((RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].mode == RL_TRIANGLES) &&
(RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount%3 == 0))
{
rlCheckRenderBatchLimit(3 + 1);
}
else if ((RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].mode == RL_QUADS) &&
(RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount%4 == 0))
{
rlCheckRenderBatchLimit(4 + 1);
}
}
// Add vertices // Add vertices
RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].vertices[3*RLGL.State.vertexCounter] = tx; RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].vertices[3*RLGL.State.vertexCounter] = tx;
RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].vertices[3*RLGL.State.vertexCounter + 1] = ty; RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].vertices[3*RLGL.State.vertexCounter + 1] = ty;
@ -1358,10 +1375,7 @@ void rlVertex3f(float x, float y, float z)
RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].colors[4*RLGL.State.vertexCounter + 3] = RLGL.State.colora; RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].colors[4*RLGL.State.vertexCounter + 3] = RLGL.State.colora;
RLGL.State.vertexCounter++; RLGL.State.vertexCounter++;
RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount++; RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount++;
}
else TRACELOG(RL_LOG_ERROR, "RLGL: Batch elements overflow");
} }
// Define one vertex (position) // Define one vertex (position)
@ -2211,22 +2225,22 @@ int rlGetVersion(void)
{ {
int glVersion = 0; int glVersion = 0;
#if defined(GRAPHICS_API_OPENGL_11) #if defined(GRAPHICS_API_OPENGL_11)
glVersion = OPENGL_11; glVersion = RL_OPENGL_11;
#endif #endif
#if defined(GRAPHICS_API_OPENGL_21) #if defined(GRAPHICS_API_OPENGL_21)
#if defined(__APPLE__) #if defined(__APPLE__)
glVersion = OPENGL_33; // NOTE: Force OpenGL 3.3 on OSX glVersion = RL_OPENGL_33; // NOTE: Force OpenGL 3.3 on OSX
#else #else
glVersion = OPENGL_21; glVersion = RL_OPENGL_21;
#endif #endif
#elif defined(GRAPHICS_API_OPENGL_33) #elif defined(GRAPHICS_API_OPENGL_33)
glVersion = OPENGL_33; glVersion = RL_OPENGL_33;
#endif #endif
#if defined(GRAPHICS_API_OPENGL_43) #if defined(GRAPHICS_API_OPENGL_43)
glVersion = OPENGL_43; glVersion = RL_OPENGL_43;
#endif #endif
#if defined(GRAPHICS_API_OPENGL_ES2) #if defined(GRAPHICS_API_OPENGL_ES2)
glVersion = OPENGL_ES_20; glVersion = RL_OPENGL_ES_20;
#endif #endif
return glVersion; return glVersion;
} }
@ -2696,10 +2710,12 @@ bool rlCheckRenderBatchLimit(int vCount)
if ((RLGL.State.vertexCounter + vCount) >= if ((RLGL.State.vertexCounter + vCount) >=
(RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].elementCount*4)) (RLGL.currentBatch->vertexBuffer[RLGL.currentBatch->currentBuffer].elementCount*4))
{ {
overflow = true;
// Store current primitive drawing mode and texture id
int currentMode = RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].mode; int currentMode = RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].mode;
int currentTexture = RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].textureId; int currentTexture = RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].textureId;
overflow = true;
rlDrawRenderBatch(RLGL.currentBatch); // NOTE: Stereo rendering is checked inside rlDrawRenderBatch(RLGL.currentBatch); // NOTE: Stereo rendering is checked inside
// Restore state of last batch so we can continue adding vertices // Restore state of last batch so we can continue adding vertices

View File

@ -163,11 +163,6 @@ static ModelAnimation *LoadModelAnimationsM3D(const char *fileName, unsigned int
// Draw a line in 3D world space // Draw a line in 3D world space
void DrawLine3D(Vector3 startPos, Vector3 endPos, Color color) void DrawLine3D(Vector3 startPos, Vector3 endPos, Color color)
{ {
// WARNING: Be careful with internal buffer vertex alignment
// when using RL_LINES or RL_TRIANGLES, data is aligned to fit
// lines-triangles-quads in the same indexed buffers!!!
rlCheckRenderBatchLimit(8);
rlBegin(RL_LINES); rlBegin(RL_LINES);
rlColor4ub(color.r, color.g, color.b, color.a); rlColor4ub(color.r, color.g, color.b, color.a);
rlVertex3f(startPos.x, startPos.y, startPos.z); rlVertex3f(startPos.x, startPos.y, startPos.z);
@ -178,8 +173,6 @@ void DrawLine3D(Vector3 startPos, Vector3 endPos, Color color)
// Draw a point in 3D space, actually a small line // Draw a point in 3D space, actually a small line
void DrawPoint3D(Vector3 position, Color color) void DrawPoint3D(Vector3 position, Color color)
{ {
rlCheckRenderBatchLimit(8);
rlPushMatrix(); rlPushMatrix();
rlTranslatef(position.x, position.y, position.z); rlTranslatef(position.x, position.y, position.z);
rlBegin(RL_LINES); rlBegin(RL_LINES);
@ -193,8 +186,6 @@ void DrawPoint3D(Vector3 position, Color color)
// Draw a circle in 3D world space // Draw a circle in 3D world space
void DrawCircle3D(Vector3 center, float radius, Vector3 rotationAxis, float rotationAngle, Color color) void DrawCircle3D(Vector3 center, float radius, Vector3 rotationAxis, float rotationAngle, Color color)
{ {
rlCheckRenderBatchLimit(2*36);
rlPushMatrix(); rlPushMatrix();
rlTranslatef(center.x, center.y, center.z); rlTranslatef(center.x, center.y, center.z);
rlRotatef(rotationAngle, rotationAxis.x, rotationAxis.y, rotationAxis.z); rlRotatef(rotationAngle, rotationAxis.x, rotationAxis.y, rotationAxis.z);
@ -214,8 +205,6 @@ void DrawCircle3D(Vector3 center, float radius, Vector3 rotationAxis, float rota
// Draw a color-filled triangle (vertex in counter-clockwise order!) // Draw a color-filled triangle (vertex in counter-clockwise order!)
void DrawTriangle3D(Vector3 v1, Vector3 v2, Vector3 v3, Color color) void DrawTriangle3D(Vector3 v1, Vector3 v2, Vector3 v3, Color color)
{ {
rlCheckRenderBatchLimit(8);
rlBegin(RL_TRIANGLES); rlBegin(RL_TRIANGLES);
rlColor4ub(color.r, color.g, color.b, color.a); rlColor4ub(color.r, color.g, color.b, color.a);
rlVertex3f(v1.x, v1.y, v1.z); rlVertex3f(v1.x, v1.y, v1.z);
@ -227,9 +216,7 @@ void DrawTriangle3D(Vector3 v1, Vector3 v2, Vector3 v3, Color color)
// Draw a triangle strip defined by points // Draw a triangle strip defined by points
void DrawTriangleStrip3D(Vector3 *points, int pointCount, Color color) void DrawTriangleStrip3D(Vector3 *points, int pointCount, Color color)
{ {
if (pointCount >= 3) if (pointCount < 3) return;
{
rlCheckRenderBatchLimit(3*(pointCount - 2));
rlBegin(RL_TRIANGLES); rlBegin(RL_TRIANGLES);
rlColor4ub(color.r, color.g, color.b, color.a); rlColor4ub(color.r, color.g, color.b, color.a);
@ -250,7 +237,6 @@ void DrawTriangleStrip3D(Vector3 *points, int pointCount, Color color)
} }
} }
rlEnd(); rlEnd();
}
} }
// Draw cube // Draw cube
@ -261,8 +247,6 @@ void DrawCube(Vector3 position, float width, float height, float length, Color c
float y = 0.0f; float y = 0.0f;
float z = 0.0f; float z = 0.0f;
rlCheckRenderBatchLimit(36);
rlPushMatrix(); rlPushMatrix();
// NOTE: Transformation is applied in inverse order (scale -> rotate -> translate) // NOTE: Transformation is applied in inverse order (scale -> rotate -> translate)
rlTranslatef(position.x, position.y, position.z); rlTranslatef(position.x, position.y, position.z);
@ -342,65 +326,67 @@ void DrawCubeWires(Vector3 position, float width, float height, float length, Co
float y = 0.0f; float y = 0.0f;
float z = 0.0f; float z = 0.0f;
rlCheckRenderBatchLimit(36);
rlPushMatrix(); rlPushMatrix();
rlTranslatef(position.x, position.y, position.z); rlTranslatef(position.x, position.y, position.z);
rlBegin(RL_LINES); rlBegin(RL_LINES);
rlColor4ub(color.r, color.g, color.b, color.a); rlColor4ub(color.r, color.g, color.b, color.a);
// Front face ----------------------------------------------------- // Front face
//------------------------------------------------------------------
// Bottom line // Bottom line
rlVertex3f(x-width/2, y-height/2, z+length/2); // Bottom left rlVertex3f(x - width/2, y - height/2, z + length/2); // Bottom left
rlVertex3f(x+width/2, y-height/2, z+length/2); // Bottom right rlVertex3f(x + width/2, y - height/2, z + length/2); // Bottom right
// Left line // Left line
rlVertex3f(x+width/2, y-height/2, z+length/2); // Bottom right rlVertex3f(x + width/2, y - height/2, z + length/2); // Bottom right
rlVertex3f(x+width/2, y+height/2, z+length/2); // Top right rlVertex3f(x + width/2, y + height/2, z + length/2); // Top right
// Top line // Top line
rlVertex3f(x+width/2, y+height/2, z+length/2); // Top right rlVertex3f(x + width/2, y + height/2, z + length/2); // Top right
rlVertex3f(x-width/2, y+height/2, z+length/2); // Top left rlVertex3f(x - width/2, y + height/2, z + length/2); // Top left
// Right line // Right line
rlVertex3f(x-width/2, y+height/2, z+length/2); // Top left rlVertex3f(x - width/2, y + height/2, z + length/2); // Top left
rlVertex3f(x-width/2, y-height/2, z+length/2); // Bottom left rlVertex3f(x - width/2, y - height/2, z + length/2); // Bottom left
// Back face ------------------------------------------------------ // Back face
//------------------------------------------------------------------
// Bottom line // Bottom line
rlVertex3f(x-width/2, y-height/2, z-length/2); // Bottom left rlVertex3f(x - width/2, y - height/2, z - length/2); // Bottom left
rlVertex3f(x+width/2, y-height/2, z-length/2); // Bottom right rlVertex3f(x + width/2, y - height/2, z - length/2); // Bottom right
// Left line // Left line
rlVertex3f(x+width/2, y-height/2, z-length/2); // Bottom right rlVertex3f(x + width/2, y - height/2, z - length/2); // Bottom right
rlVertex3f(x+width/2, y+height/2, z-length/2); // Top right rlVertex3f(x + width/2, y + height/2, z - length/2); // Top right
// Top line // Top line
rlVertex3f(x+width/2, y+height/2, z-length/2); // Top right rlVertex3f(x + width/2, y + height/2, z - length/2); // Top right
rlVertex3f(x-width/2, y+height/2, z-length/2); // Top left rlVertex3f(x - width/2, y + height/2, z - length/2); // Top left
// Right line // Right line
rlVertex3f(x-width/2, y+height/2, z-length/2); // Top left rlVertex3f(x - width/2, y + height/2, z - length/2); // Top left
rlVertex3f(x-width/2, y-height/2, z-length/2); // Bottom left rlVertex3f(x - width/2, y - height/2, z - length/2); // Bottom left
// Top face ------------------------------------------------------- // Top face
//------------------------------------------------------------------
// Left line // Left line
rlVertex3f(x-width/2, y+height/2, z+length/2); // Top left front rlVertex3f(x - width/2, y + height/2, z + length/2); // Top left front
rlVertex3f(x-width/2, y+height/2, z-length/2); // Top left back rlVertex3f(x - width/2, y + height/2, z - length/2); // Top left back
// Right line // Right line
rlVertex3f(x+width/2, y+height/2, z+length/2); // Top right front rlVertex3f(x + width/2, y + height/2, z + length/2); // Top right front
rlVertex3f(x+width/2, y+height/2, z-length/2); // Top right back rlVertex3f(x + width/2, y + height/2, z - length/2); // Top right back
// Bottom face --------------------------------------------------- // Bottom face
//------------------------------------------------------------------
// Left line // Left line
rlVertex3f(x-width/2, y-height/2, z+length/2); // Top left front rlVertex3f(x - width/2, y - height/2, z + length/2); // Top left front
rlVertex3f(x-width/2, y-height/2, z-length/2); // Top left back rlVertex3f(x - width/2, y - height/2, z - length/2); // Top left back
// Right line // Right line
rlVertex3f(x+width/2, y-height/2, z+length/2); // Top right front rlVertex3f(x + width/2, y - height/2, z + length/2); // Top right front
rlVertex3f(x+width/2, y-height/2, z-length/2); // Top right back rlVertex3f(x + width/2, y - height/2, z - length/2); // Top right back
rlEnd(); rlEnd();
rlPopMatrix(); rlPopMatrix();
} }
@ -419,8 +405,6 @@ void DrawCubeTexture(Texture2D texture, Vector3 position, float width, float hei
float y = position.y; float y = position.y;
float z = position.z; float z = position.z;
rlCheckRenderBatchLimit(36);
rlSetTexture(texture.id); rlSetTexture(texture.id);
//rlPushMatrix(); //rlPushMatrix();
@ -482,8 +466,6 @@ void DrawCubeTextureRec(Texture2D texture, Rectangle source, Vector3 position, f
float texWidth = (float)texture.width; float texWidth = (float)texture.width;
float texHeight = (float)texture.height; float texHeight = (float)texture.height;
rlCheckRenderBatchLimit(36);
rlSetTexture(texture.id); rlSetTexture(texture.id);
rlBegin(RL_QUADS); rlBegin(RL_QUADS);
@ -569,9 +551,6 @@ void DrawSphere(Vector3 centerPos, float radius, Color color)
// Draw sphere with extended parameters // Draw sphere with extended parameters
void DrawSphereEx(Vector3 centerPos, float radius, int rings, int slices, Color color) void DrawSphereEx(Vector3 centerPos, float radius, int rings, int slices, Color color)
{ {
int numVertex = (rings + 2)*slices*6;
rlCheckRenderBatchLimit(numVertex);
rlPushMatrix(); rlPushMatrix();
// NOTE: Transformation is applied in inverse order (scale -> translate) // NOTE: Transformation is applied in inverse order (scale -> translate)
rlTranslatef(centerPos.x, centerPos.y, centerPos.z); rlTranslatef(centerPos.x, centerPos.y, centerPos.z);
@ -612,9 +591,6 @@ void DrawSphereEx(Vector3 centerPos, float radius, int rings, int slices, Color
// Draw sphere wires // Draw sphere wires
void DrawSphereWires(Vector3 centerPos, float radius, int rings, int slices, Color color) void DrawSphereWires(Vector3 centerPos, float radius, int rings, int slices, Color color)
{ {
int numVertex = (rings + 2)*slices*6;
rlCheckRenderBatchLimit(numVertex);
rlPushMatrix(); rlPushMatrix();
// NOTE: Transformation is applied in inverse order (scale -> translate) // NOTE: Transformation is applied in inverse order (scale -> translate)
rlTranslatef(centerPos.x, centerPos.y, centerPos.z); rlTranslatef(centerPos.x, centerPos.y, centerPos.z);
@ -659,9 +635,6 @@ void DrawCylinder(Vector3 position, float radiusTop, float radiusBottom, float h
{ {
if (sides < 3) sides = 3; if (sides < 3) sides = 3;
int numVertex = sides*6;
rlCheckRenderBatchLimit(numVertex);
rlPushMatrix(); rlPushMatrix();
rlTranslatef(position.x, position.y, position.z); rlTranslatef(position.x, position.y, position.z);
@ -718,9 +691,6 @@ void DrawCylinderEx(Vector3 startPos, Vector3 endPos, float startRadius, float e
{ {
if (sides < 3) sides = 3; if (sides < 3) sides = 3;
int numVertex = sides*6;
rlCheckRenderBatchLimit(numVertex);
Vector3 direction = { endPos.x - startPos.x, endPos.y - startPos.y, endPos.z - startPos.z }; Vector3 direction = { endPos.x - startPos.x, endPos.y - startPos.y, endPos.z - startPos.z };
if ((direction.x == 0) && (direction.y == 0) && (direction.z == 0)) return; if ((direction.x == 0) && (direction.y == 0) && (direction.z == 0)) return;
@ -777,9 +747,6 @@ void DrawCylinderWires(Vector3 position, float radiusTop, float radiusBottom, fl
{ {
if (sides < 3) sides = 3; if (sides < 3) sides = 3;
int numVertex = sides*8;
rlCheckRenderBatchLimit(numVertex);
rlPushMatrix(); rlPushMatrix();
rlTranslatef(position.x, position.y, position.z); rlTranslatef(position.x, position.y, position.z);
@ -811,9 +778,6 @@ void DrawCylinderWiresEx(Vector3 startPos, Vector3 endPos, float startRadius, fl
{ {
if (sides < 3) sides = 3; if (sides < 3) sides = 3;
int numVertex = sides*6;
rlCheckRenderBatchLimit(numVertex);
Vector3 direction = { endPos.x - startPos.x, endPos.y - startPos.y, endPos.z - startPos.z }; Vector3 direction = { endPos.x - startPos.x, endPos.y - startPos.y, endPos.z - startPos.z };
if ((direction.x == 0) && (direction.y == 0) && (direction.z == 0))return; if ((direction.x == 0) && (direction.y == 0) && (direction.z == 0))return;
@ -853,12 +817,9 @@ void DrawCylinderWiresEx(Vector3 startPos, Vector3 endPos, float startRadius, fl
rlEnd(); rlEnd();
} }
// Draw a plane // Draw a plane
void DrawPlane(Vector3 centerPos, Vector2 size, Color color) void DrawPlane(Vector3 centerPos, Vector2 size, Color color)
{ {
rlCheckRenderBatchLimit(4);
// NOTE: Plane is always created on XZ ground // NOTE: Plane is always created on XZ ground
rlPushMatrix(); rlPushMatrix();
rlTranslatef(centerPos.x, centerPos.y, centerPos.z); rlTranslatef(centerPos.x, centerPos.y, centerPos.z);
@ -895,8 +856,6 @@ void DrawGrid(int slices, float spacing)
{ {
int halfSlices = slices/2; int halfSlices = slices/2;
rlCheckRenderBatchLimit((slices + 2)*4);
rlBegin(RL_LINES); rlBegin(RL_LINES);
for (int i = -halfSlices; i <= halfSlices; i++) for (int i = -halfSlices; i <= halfSlices; i++)
{ {
@ -3421,8 +3380,6 @@ void DrawBillboardPro(Camera camera, Texture2D texture, Rectangle source, Vector
bottomRight = Vector3Add(bottomRight, position); bottomRight = Vector3Add(bottomRight, position);
bottomLeft = Vector3Add(bottomLeft, position); bottomLeft = Vector3Add(bottomLeft, position);
rlCheckRenderBatchLimit(8);
rlSetTexture(texture.id); rlSetTexture(texture.id);
rlBegin(RL_QUADS); rlBegin(RL_QUADS);
@ -5372,9 +5329,9 @@ static Model LoadM3D(const char *fileName)
{ {
model.bones[i].parent = m3d->bone[i].parent; model.bones[i].parent = m3d->bone[i].parent;
strncpy(model.bones[i].name, m3d->bone[i].name, sizeof(model.bones[i].name)); strncpy(model.bones[i].name, m3d->bone[i].name, sizeof(model.bones[i].name));
model.bindPose[i].translation.x = m3d->vertex[m3d->bone[i].pos].x; model.bindPose[i].translation.x = m3d->vertex[m3d->bone[i].pos].x*m3d->scale;
model.bindPose[i].translation.y = m3d->vertex[m3d->bone[i].pos].y; model.bindPose[i].translation.y = m3d->vertex[m3d->bone[i].pos].y*m3d->scale;
model.bindPose[i].translation.z = m3d->vertex[m3d->bone[i].pos].z; model.bindPose[i].translation.z = m3d->vertex[m3d->bone[i].pos].z*m3d->scale;
model.bindPose[i].rotation.x = m3d->vertex[m3d->bone[i].ori].x; model.bindPose[i].rotation.x = m3d->vertex[m3d->bone[i].ori].x;
model.bindPose[i].rotation.y = m3d->vertex[m3d->bone[i].ori].y; model.bindPose[i].rotation.y = m3d->vertex[m3d->bone[i].ori].y;
model.bindPose[i].rotation.z = m3d->vertex[m3d->bone[i].ori].z; model.bindPose[i].rotation.z = m3d->vertex[m3d->bone[i].ori].z;
@ -5490,9 +5447,9 @@ static ModelAnimation *LoadModelAnimationsM3D(const char *fileName, unsigned int
{ {
for (j = 0; j < m3d->numbone; j++) for (j = 0; j < m3d->numbone; j++)
{ {
animations[a].framePoses[i][j].translation.x = m3d->vertex[pose[j].pos].x; animations[a].framePoses[i][j].translation.x = m3d->vertex[pose[j].pos].x*m3d->scale;
animations[a].framePoses[i][j].translation.y = m3d->vertex[pose[j].pos].y; animations[a].framePoses[i][j].translation.y = m3d->vertex[pose[j].pos].y*m3d->scale;
animations[a].framePoses[i][j].translation.z = m3d->vertex[pose[j].pos].z; animations[a].framePoses[i][j].translation.z = m3d->vertex[pose[j].pos].z*m3d->scale;
animations[a].framePoses[i][j].rotation.x = m3d->vertex[pose[j].ori].x; animations[a].framePoses[i][j].rotation.x = m3d->vertex[pose[j].ori].x;
animations[a].framePoses[i][j].rotation.y = m3d->vertex[pose[j].ori].y; animations[a].framePoses[i][j].rotation.y = m3d->vertex[pose[j].ori].y;
animations[a].framePoses[i][j].rotation.z = m3d->vertex[pose[j].ori].z; animations[a].framePoses[i][j].rotation.z = m3d->vertex[pose[j].ori].z;

View File

@ -106,8 +106,8 @@ void DrawPixel(int posX, int posY, Color color)
{ {
rlBegin(RL_LINES); rlBegin(RL_LINES);
rlColor4ub(color.r, color.g, color.b, color.a); rlColor4ub(color.r, color.g, color.b, color.a);
rlVertex2i(posX, posY); rlVertex2f(posX, posY);
rlVertex2i(posX + 1, posY + 1); rlVertex2f(posX + 1, posY + 1);
rlEnd(); rlEnd();
} }
@ -126,8 +126,8 @@ void DrawLine(int startPosX, int startPosY, int endPosX, int endPosY, Color colo
{ {
rlBegin(RL_LINES); rlBegin(RL_LINES);
rlColor4ub(color.r, color.g, color.b, color.a); rlColor4ub(color.r, color.g, color.b, color.a);
rlVertex2i(startPosX, startPosY); rlVertex2f(startPosX, startPosY);
rlVertex2i(endPosX, endPosY); rlVertex2f(endPosX, endPosY);
rlEnd(); rlEnd();
} }
@ -238,8 +238,6 @@ void DrawLineStrip(Vector2 *points, int pointCount, Color color)
{ {
if (pointCount >= 2) if (pointCount >= 2)
{ {
rlCheckRenderBatchLimit(pointCount);
rlBegin(RL_LINES); rlBegin(RL_LINES);
rlColor4ub(color.r, color.g, color.b, color.a); rlColor4ub(color.r, color.g, color.b, color.a);
@ -287,8 +285,6 @@ void DrawCircleSector(Vector2 center, float radius, float startAngle, float endA
float angle = startAngle; float angle = startAngle;
#if defined(SUPPORT_QUADS_DRAW_MODE) #if defined(SUPPORT_QUADS_DRAW_MODE)
rlCheckRenderBatchLimit(4*segments/2);
rlSetTexture(texShapes.id); rlSetTexture(texShapes.id);
rlBegin(RL_QUADS); rlBegin(RL_QUADS);
@ -333,8 +329,6 @@ void DrawCircleSector(Vector2 center, float radius, float startAngle, float endA
rlSetTexture(0); rlSetTexture(0);
#else #else
rlCheckRenderBatchLimit(3*segments);
rlBegin(RL_TRIANGLES); rlBegin(RL_TRIANGLES);
for (int i = 0; i < segments; i++) for (int i = 0; i < segments; i++)
{ {
@ -377,13 +371,7 @@ void DrawCircleSectorLines(Vector2 center, float radius, float startAngle, float
float stepLength = (endAngle - startAngle)/(float)segments; float stepLength = (endAngle - startAngle)/(float)segments;
float angle = startAngle; float angle = startAngle;
// Hide the cap lines when the circle is full
bool showCapLines = true; bool showCapLines = true;
int limit = 2*(segments + 2);
if ((int)(endAngle - startAngle)%360 == 0) { limit = 2*segments; showCapLines = false; }
rlCheckRenderBatchLimit(limit);
rlBegin(RL_LINES); rlBegin(RL_LINES);
if (showCapLines) if (showCapLines)
@ -416,8 +404,6 @@ void DrawCircleSectorLines(Vector2 center, float radius, float startAngle, float
// 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)
{ {
rlCheckRenderBatchLimit(3*36);
rlBegin(RL_TRIANGLES); rlBegin(RL_TRIANGLES);
for (int i = 0; i < 360; i += 10) for (int i = 0; i < 360; i += 10)
{ {
@ -441,8 +427,6 @@ 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)
{ {
rlCheckRenderBatchLimit(2*36);
rlBegin(RL_LINES); rlBegin(RL_LINES);
rlColor4ub(color.r, color.g, color.b, color.a); rlColor4ub(color.r, color.g, color.b, color.a);
@ -458,8 +442,6 @@ void DrawCircleLines(int centerX, int centerY, float radius, Color color)
// Draw ellipse // Draw ellipse
void DrawEllipse(int centerX, int centerY, float radiusH, float radiusV, Color color) void DrawEllipse(int centerX, int centerY, float radiusH, float radiusV, Color color)
{ {
rlCheckRenderBatchLimit(3*36);
rlBegin(RL_TRIANGLES); rlBegin(RL_TRIANGLES);
for (int i = 0; i < 360; i += 10) for (int i = 0; i < 360; i += 10)
{ {
@ -474,8 +456,6 @@ void DrawEllipse(int centerX, int centerY, float radiusH, float radiusV, Color c
// Draw ellipse outline // Draw ellipse outline
void DrawEllipseLines(int centerX, int centerY, float radiusH, float radiusV, Color color) void DrawEllipseLines(int centerX, int centerY, float radiusH, float radiusV, Color color)
{ {
rlCheckRenderBatchLimit(2*36);
rlBegin(RL_LINES); rlBegin(RL_LINES);
for (int i = 0; i < 360; i += 10) for (int i = 0; i < 360; i += 10)
{ {
@ -532,8 +512,6 @@ void DrawRing(Vector2 center, float innerRadius, float outerRadius, float startA
float angle = startAngle; float angle = startAngle;
#if defined(SUPPORT_QUADS_DRAW_MODE) #if defined(SUPPORT_QUADS_DRAW_MODE)
rlCheckRenderBatchLimit(4*segments);
rlSetTexture(texShapes.id); rlSetTexture(texShapes.id);
rlBegin(RL_QUADS); rlBegin(RL_QUADS);
@ -559,8 +537,6 @@ void DrawRing(Vector2 center, float innerRadius, float outerRadius, float startA
rlSetTexture(0); rlSetTexture(0);
#else #else
rlCheckRenderBatchLimit(6*segments);
rlBegin(RL_TRIANGLES); rlBegin(RL_TRIANGLES);
for (int i = 0; i < segments; i++) for (int i = 0; i < segments; i++)
{ {
@ -623,12 +599,7 @@ void DrawRingLines(Vector2 center, float innerRadius, float outerRadius, float s
float stepLength = (endAngle - startAngle)/(float)segments; float stepLength = (endAngle - startAngle)/(float)segments;
float angle = startAngle; float angle = startAngle;
bool showCapLines = true; bool showCapLines = true;
int limit = 4*(segments + 1);
if ((int)(endAngle - startAngle)%360 == 0) { limit = 4*segments; showCapLines = false; }
rlCheckRenderBatchLimit(limit);
rlBegin(RL_LINES); rlBegin(RL_LINES);
if (showCapLines) if (showCapLines)
@ -720,8 +691,6 @@ void DrawRectanglePro(Rectangle rec, Vector2 origin, float rotation, Color color
} }
#if defined(SUPPORT_QUADS_DRAW_MODE) #if defined(SUPPORT_QUADS_DRAW_MODE)
rlCheckRenderBatchLimit(4);
rlSetTexture(texShapes.id); rlSetTexture(texShapes.id);
rlBegin(RL_QUADS); rlBegin(RL_QUADS);
@ -745,8 +714,6 @@ void DrawRectanglePro(Rectangle rec, Vector2 origin, float rotation, Color color
rlSetTexture(0); rlSetTexture(0);
#else #else
rlCheckRenderBatchLimit(6);
rlBegin(RL_TRIANGLES); rlBegin(RL_TRIANGLES);
rlColor4ub(color.r, color.g, color.b, color.a); rlColor4ub(color.r, color.g, color.b, color.a);
@ -781,8 +748,6 @@ void DrawRectangleGradientH(int posX, int posY, int width, int height, Color col
// NOTE: Colors refer to corners, starting at top-lef corner and counter-clockwise // NOTE: Colors refer to corners, starting at top-lef corner and counter-clockwise
void DrawRectangleGradientEx(Rectangle rec, Color col1, Color col2, Color col3, Color col4) void DrawRectangleGradientEx(Rectangle rec, Color col1, Color col2, Color col3, Color col4)
{ {
rlCheckRenderBatchLimit(4);
rlSetTexture(texShapes.id); rlSetTexture(texShapes.id);
rlBegin(RL_QUADS); rlBegin(RL_QUADS);
@ -821,17 +786,17 @@ void DrawRectangleLines(int posX, int posY, int width, int height, Color color)
#else #else
rlBegin(RL_LINES); rlBegin(RL_LINES);
rlColor4ub(color.r, color.g, color.b, color.a); rlColor4ub(color.r, color.g, color.b, color.a);
rlVertex2i(posX + 1, posY + 1); rlVertex2f(posX + 1, posY + 1);
rlVertex2i(posX + width, posY + 1); rlVertex2f(posX + width, posY + 1);
rlVertex2i(posX + width, posY + 1); rlVertex2f(posX + width, posY + 1);
rlVertex2i(posX + width, posY + height); rlVertex2f(posX + width, posY + height);
rlVertex2i(posX + width, posY + height); rlVertex2f(posX + width, posY + height);
rlVertex2i(posX + 1, posY + height); rlVertex2f(posX + 1, posY + height);
rlVertex2i(posX + 1, posY + height); rlVertex2f(posX + 1, posY + height);
rlVertex2i(posX + 1, posY + 1); rlVertex2f(posX + 1, posY + 1);
rlEnd(); rlEnd();
#endif #endif
} }
@ -923,8 +888,6 @@ void DrawRectangleRounded(Rectangle rec, float roundness, int segments, Color co
const float angles[4] = { 180.0f, 90.0f, 0.0f, 270.0f }; const float angles[4] = { 180.0f, 90.0f, 0.0f, 270.0f };
#if defined(SUPPORT_QUADS_DRAW_MODE) #if defined(SUPPORT_QUADS_DRAW_MODE)
rlCheckRenderBatchLimit(16*segments/2 + 5*4);
rlSetTexture(texShapes.id); rlSetTexture(texShapes.id);
rlBegin(RL_QUADS); rlBegin(RL_QUADS);
@ -1022,8 +985,6 @@ void DrawRectangleRounded(Rectangle rec, float roundness, int segments, Color co
rlEnd(); rlEnd();
rlSetTexture(0); rlSetTexture(0);
#else #else
rlCheckRenderBatchLimit(12*segments + 5*6); // 4 corners with 3 vertices per segment + 5 rectangles with 6 vertices each
rlBegin(RL_TRIANGLES); rlBegin(RL_TRIANGLES);
// Draw all of the 4 corners: [1] Upper Left Corner, [3] Upper Right Corner, [5] Lower Right Corner, [7] Lower Left Corner // Draw all of the 4 corners: [1] Upper Left Corner, [3] Upper Right Corner, [5] Lower Right Corner, [7] Lower Left Corner
@ -1155,8 +1116,6 @@ void DrawRectangleRoundedLines(Rectangle rec, float roundness, int segments, flo
if (lineThick > 1) if (lineThick > 1)
{ {
#if defined(SUPPORT_QUADS_DRAW_MODE) #if defined(SUPPORT_QUADS_DRAW_MODE)
rlCheckRenderBatchLimit(4*4*segments + 4*4); // 4 corners with 4 vertices for each segment + 4 rectangles with 4 vertices each
rlSetTexture(texShapes.id); rlSetTexture(texShapes.id);
rlBegin(RL_QUADS); rlBegin(RL_QUADS);
@ -1229,8 +1188,6 @@ void DrawRectangleRoundedLines(Rectangle rec, float roundness, int segments, flo
rlEnd(); rlEnd();
rlSetTexture(0); rlSetTexture(0);
#else #else
rlCheckRenderBatchLimit(4*6*segments + 4*6); // 4 corners with 6(2*3) vertices for each segment + 4 rectangles with 6 vertices each
rlBegin(RL_TRIANGLES); rlBegin(RL_TRIANGLES);
// Draw all of the 4 corners first: Upper Left Corner, Upper Right Corner, Lower Right Corner, Lower Left Corner // Draw all of the 4 corners first: Upper Left Corner, Upper Right Corner, Lower Right Corner, Lower Left Corner
@ -1296,8 +1253,6 @@ void DrawRectangleRoundedLines(Rectangle rec, float roundness, int segments, flo
else else
{ {
// Use LINES to draw the outline // Use LINES to draw the outline
rlCheckRenderBatchLimit(8*segments + 4*2); // 4 corners with 2 vertices for each segment + 4 rectangles with 2 vertices each
rlBegin(RL_LINES); rlBegin(RL_LINES);
// Draw all of the 4 corners first: Upper Left Corner, Upper Right Corner, Lower Right Corner, Lower Left Corner // Draw all of the 4 corners first: Upper Left Corner, Upper Right Corner, Lower Right Corner, Lower Left Corner
@ -1332,8 +1287,6 @@ void DrawRectangleRoundedLines(Rectangle rec, float roundness, int segments, flo
void DrawTriangle(Vector2 v1, Vector2 v2, Vector2 v3, Color color) void DrawTriangle(Vector2 v1, Vector2 v2, Vector2 v3, Color color)
{ {
#if defined(SUPPORT_QUADS_DRAW_MODE) #if defined(SUPPORT_QUADS_DRAW_MODE)
rlCheckRenderBatchLimit(4);
rlSetTexture(texShapes.id); rlSetTexture(texShapes.id);
rlBegin(RL_QUADS); rlBegin(RL_QUADS);
@ -1354,8 +1307,6 @@ void DrawTriangle(Vector2 v1, Vector2 v2, Vector2 v3, Color color)
rlSetTexture(0); rlSetTexture(0);
#else #else
rlCheckRenderBatchLimit(3);
rlBegin(RL_TRIANGLES); rlBegin(RL_TRIANGLES);
rlColor4ub(color.r, color.g, color.b, color.a); rlColor4ub(color.r, color.g, color.b, color.a);
rlVertex2f(v1.x, v1.y); rlVertex2f(v1.x, v1.y);
@ -1369,8 +1320,6 @@ void DrawTriangle(Vector2 v1, Vector2 v2, Vector2 v3, Color color)
// NOTE: Vertex must be provided in counter-clockwise order // NOTE: Vertex must be provided in counter-clockwise order
void DrawTriangleLines(Vector2 v1, Vector2 v2, Vector2 v3, Color color) void DrawTriangleLines(Vector2 v1, Vector2 v2, Vector2 v3, Color color)
{ {
rlCheckRenderBatchLimit(6);
rlBegin(RL_LINES); rlBegin(RL_LINES);
rlColor4ub(color.r, color.g, color.b, color.a); rlColor4ub(color.r, color.g, color.b, color.a);
rlVertex2f(v1.x, v1.y); rlVertex2f(v1.x, v1.y);
@ -1391,8 +1340,6 @@ void DrawTriangleFan(Vector2 *points, int pointCount, Color color)
{ {
if (pointCount >= 3) if (pointCount >= 3)
{ {
rlCheckRenderBatchLimit((pointCount - 2)*4);
rlSetTexture(texShapes.id); rlSetTexture(texShapes.id);
rlBegin(RL_QUADS); rlBegin(RL_QUADS);
rlColor4ub(color.r, color.g, color.b, color.a); rlColor4ub(color.r, color.g, color.b, color.a);
@ -1422,8 +1369,6 @@ void DrawTriangleStrip(Vector2 *points, int pointCount, Color color)
{ {
if (pointCount >= 3) if (pointCount >= 3)
{ {
rlCheckRenderBatchLimit(3*(pointCount - 2));
rlBegin(RL_TRIANGLES); rlBegin(RL_TRIANGLES);
rlColor4ub(color.r, color.g, color.b, color.a); rlColor4ub(color.r, color.g, color.b, color.a);
@ -1450,17 +1395,7 @@ void DrawTriangleStrip(Vector2 *points, int pointCount, Color color)
void DrawPoly(Vector2 center, int sides, float radius, float rotation, Color color) void DrawPoly(Vector2 center, int sides, float radius, float rotation, Color color)
{ {
if (sides < 3) sides = 3; if (sides < 3) sides = 3;
float centralAngle = 0.0f; float centralAngle = rotation;
#if defined(SUPPORT_QUADS_DRAW_MODE)
rlCheckRenderBatchLimit(4*sides); // Each side is a quad
#else
rlCheckRenderBatchLimit(3*sides);
#endif
rlPushMatrix();
rlTranslatef(center.x, center.y, 0.0f);
rlRotatef(rotation, 0.0f, 0.0f, 1.0f);
#if defined(SUPPORT_QUADS_DRAW_MODE) #if defined(SUPPORT_QUADS_DRAW_MODE)
rlSetTexture(texShapes.id); rlSetTexture(texShapes.id);
@ -1471,17 +1406,17 @@ void DrawPoly(Vector2 center, int sides, float radius, float rotation, Color col
rlColor4ub(color.r, color.g, color.b, color.a); rlColor4ub(color.r, color.g, color.b, color.a);
rlTexCoord2f(texShapesRec.x/texShapes.width, texShapesRec.y/texShapes.height); rlTexCoord2f(texShapesRec.x/texShapes.width, texShapesRec.y/texShapes.height);
rlVertex2f(0, 0); rlVertex2f(center.x, center.y);
rlTexCoord2f(texShapesRec.x/texShapes.width, (texShapesRec.y + texShapesRec.height)/texShapes.height); rlTexCoord2f(texShapesRec.x/texShapes.width, (texShapesRec.y + texShapesRec.height)/texShapes.height);
rlVertex2f(sinf(DEG2RAD*centralAngle)*radius, cosf(DEG2RAD*centralAngle)*radius); rlVertex2f(center.x + sinf(DEG2RAD*centralAngle)*radius, center.y + cosf(DEG2RAD*centralAngle)*radius);
rlTexCoord2f((texShapesRec.x + texShapesRec.width)/texShapes.width, (texShapesRec.y + texShapesRec.height)/texShapes.height); rlTexCoord2f((texShapesRec.x + texShapesRec.width)/texShapes.width, (texShapesRec.y + texShapesRec.height)/texShapes.height);
rlVertex2f(sinf(DEG2RAD*centralAngle)*radius, cosf(DEG2RAD*centralAngle)*radius); rlVertex2f(center.x + sinf(DEG2RAD*centralAngle)*radius, center.y + cosf(DEG2RAD*centralAngle)*radius);
centralAngle += 360.0f/(float)sides; centralAngle += 360.0f/(float)sides;
rlTexCoord2f((texShapesRec.x + texShapesRec.width)/texShapes.width, texShapesRec.y/texShapes.height); rlTexCoord2f((texShapesRec.x + texShapesRec.width)/texShapes.width, texShapesRec.y/texShapes.height);
rlVertex2f(sinf(DEG2RAD*centralAngle)*radius, cosf(DEG2RAD*centralAngle)*radius); rlVertex2f(center.x + sinf(DEG2RAD*centralAngle)*radius, center.y + cosf(DEG2RAD*centralAngle)*radius);
} }
rlEnd(); rlEnd();
rlSetTexture(0); rlSetTexture(0);
@ -1491,59 +1426,41 @@ void DrawPoly(Vector2 center, int sides, float radius, float rotation, Color col
{ {
rlColor4ub(color.r, color.g, color.b, color.a); rlColor4ub(color.r, color.g, color.b, color.a);
rlVertex2f(0, 0); rlVertex2f(center.x, center.y);
rlVertex2f(sinf(DEG2RAD*centralAngle)*radius, cosf(DEG2RAD*centralAngle)*radius); rlVertex2f(center.x + sinf(DEG2RAD*centralAngle)*radius, center.y + cosf(DEG2RAD*centralAngle)*radius);
centralAngle += 360.0f/(float)sides; centralAngle += 360.0f/(float)sides;
rlVertex2f(sinf(DEG2RAD*centralAngle)*radius, cosf(DEG2RAD*centralAngle)*radius); rlVertex2f(center.x + sinf(DEG2RAD*centralAngle)*radius, center.y + cosf(DEG2RAD*centralAngle)*radius);
} }
rlEnd(); rlEnd();
#endif #endif
rlPopMatrix();
} }
// Draw a polygon outline of n sides // Draw a polygon outline of n sides
void DrawPolyLines(Vector2 center, int sides, float radius, float rotation, Color color) void DrawPolyLines(Vector2 center, int sides, float radius, float rotation, Color color)
{ {
if (sides < 3) sides = 3; if (sides < 3) sides = 3;
float centralAngle = 0.0f; float centralAngle = rotation;
rlCheckRenderBatchLimit(2*sides);
rlPushMatrix();
rlTranslatef(center.x, center.y, 0.0f);
rlRotatef(rotation, 0.0f, 0.0f, 1.0f);
rlBegin(RL_LINES); rlBegin(RL_LINES);
for (int i = 0; i < sides; i++) for (int i = 0; i < sides; i++)
{ {
rlColor4ub(color.r, color.g, color.b, color.a); rlColor4ub(color.r, color.g, color.b, color.a);
rlVertex2f(sinf(DEG2RAD*centralAngle)*radius, cosf(DEG2RAD*centralAngle)*radius); rlVertex2f(center.x + sinf(DEG2RAD*centralAngle)*radius, center.y + cosf(DEG2RAD*centralAngle)*radius);
centralAngle += 360.0f/(float)sides; centralAngle += 360.0f/(float)sides;
rlVertex2f(sinf(DEG2RAD*centralAngle)*radius, cosf(DEG2RAD*centralAngle)*radius); rlVertex2f(center.x + sinf(DEG2RAD*centralAngle)*radius, center.y + cosf(DEG2RAD*centralAngle)*radius);
} }
rlEnd(); rlEnd();
rlPopMatrix();
} }
void DrawPolyLinesEx(Vector2 center, int sides, float radius, float rotation, float lineThick, Color color) void DrawPolyLinesEx(Vector2 center, int sides, float radius, float rotation, float lineThick, Color color)
{ {
if (sides < 3) sides = 3; if (sides < 3) sides = 3;
float centralAngle = 0.0f; float centralAngle = rotation;
float exteriorAngle = 360.0f/(float)sides; float exteriorAngle = 360.0f/(float)sides;
float innerRadius = radius - (lineThick*cosf(DEG2RAD*exteriorAngle/2.0f)); float innerRadius = radius - (lineThick*cosf(DEG2RAD*exteriorAngle/2.0f));
#if defined(SUPPORT_QUADS_DRAW_MODE)
rlCheckRenderBatchLimit(4*sides);
#else
rlCheckRenderBatchLimit(6*sides);
#endif
rlPushMatrix();
rlTranslatef(center.x, center.y, 0.0f);
rlRotatef(rotation, 0.0f, 0.0f, 1.0f);
#if defined(SUPPORT_QUADS_DRAW_MODE) #if defined(SUPPORT_QUADS_DRAW_MODE)
rlSetTexture(texShapes.id); rlSetTexture(texShapes.id);
@ -1553,17 +1470,17 @@ void DrawPolyLinesEx(Vector2 center, int sides, float radius, float rotation, fl
rlColor4ub(color.r, color.g, color.b, color.a); rlColor4ub(color.r, color.g, color.b, color.a);
rlTexCoord2f(texShapesRec.x/texShapes.width, texShapesRec.y/texShapes.height); rlTexCoord2f(texShapesRec.x/texShapes.width, texShapesRec.y/texShapes.height);
rlVertex2f(sinf(DEG2RAD*centralAngle)*innerRadius, cosf(DEG2RAD*centralAngle)*innerRadius); rlVertex2f(center.x + sinf(DEG2RAD*centralAngle)*innerRadius, center.y + cosf(DEG2RAD*centralAngle)*innerRadius);
rlTexCoord2f(texShapesRec.x/texShapes.width, (texShapesRec.y + texShapesRec.height)/texShapes.height); rlTexCoord2f(texShapesRec.x/texShapes.width, (texShapesRec.y + texShapesRec.height)/texShapes.height);
rlVertex2f(sinf(DEG2RAD*centralAngle)*radius, cosf(DEG2RAD*centralAngle)*radius); rlVertex2f(center.x + sinf(DEG2RAD*centralAngle)*radius, center.y + cosf(DEG2RAD*centralAngle)*radius);
centralAngle += exteriorAngle; centralAngle += exteriorAngle;
rlTexCoord2f((texShapesRec.x + texShapesRec.width)/texShapes.width, texShapesRec.y/texShapes.height); rlTexCoord2f((texShapesRec.x + texShapesRec.width)/texShapes.width, texShapesRec.y/texShapes.height);
rlVertex2f(sinf(DEG2RAD*centralAngle)*radius, cosf(DEG2RAD*centralAngle)*radius); rlVertex2f(center.x + sinf(DEG2RAD*centralAngle)*radius, center.y + cosf(DEG2RAD*centralAngle)*radius);
rlTexCoord2f((texShapesRec.x + texShapesRec.width)/texShapes.width, (texShapesRec.y + texShapesRec.height)/texShapes.height); rlTexCoord2f((texShapesRec.x + texShapesRec.width)/texShapes.width, (texShapesRec.y + texShapesRec.height)/texShapes.height);
rlVertex2f(sinf(DEG2RAD*centralAngle)*innerRadius, cosf(DEG2RAD*centralAngle)*innerRadius); rlVertex2f(center.x + sinf(DEG2RAD*centralAngle)*innerRadius, center.y + cosf(DEG2RAD*centralAngle)*innerRadius);
} }
rlEnd(); rlEnd();
rlSetTexture(0); rlSetTexture(0);
@ -1574,19 +1491,18 @@ void DrawPolyLinesEx(Vector2 center, int sides, float radius, float rotation, fl
rlColor4ub(color.r, color.g, color.b, color.a); rlColor4ub(color.r, color.g, color.b, color.a);
float nextAngle = centralAngle + exteriorAngle; float nextAngle = centralAngle + exteriorAngle;
rlVertex2f(sinf(DEG2RAD*centralAngle)*radius, cosf(DEG2RAD*centralAngle)*radius); rlVertex2f(center.x + sinf(DEG2RAD*centralAngle)*radius, center.y + cosf(DEG2RAD*centralAngle)*radius);
rlVertex2f(sinf(DEG2RAD*centralAngle)*innerRadius, cosf(DEG2RAD*centralAngle)*innerRadius); rlVertex2f(center.x + sinf(DEG2RAD*centralAngle)*innerRadius, center.y + cosf(DEG2RAD*centralAngle)*innerRadius);
rlVertex2f(sinf(DEG2RAD*nextAngle)*radius, cosf(DEG2RAD*nextAngle)*radius); rlVertex2f(center.x + sinf(DEG2RAD*nextAngle)*radius, center.y + cosf(DEG2RAD*nextAngle)*radius);
rlVertex2f(sinf(DEG2RAD*centralAngle)*innerRadius, cosf(DEG2RAD*centralAngle)*innerRadius); rlVertex2f(center.x + sinf(DEG2RAD*centralAngle)*innerRadius, center.y + cosf(DEG2RAD*centralAngle)*innerRadius);
rlVertex2f(sinf(DEG2RAD*nextAngle)*radius, cosf(DEG2RAD*nextAngle)*radius); rlVertex2f(center.x + sinf(DEG2RAD*nextAngle)*radius, center.y + cosf(DEG2RAD*nextAngle)*radius);
rlVertex2f(sinf(DEG2RAD*nextAngle)*innerRadius, cosf(DEG2RAD*nextAngle)*innerRadius); rlVertex2f(center.x + sinf(DEG2RAD*nextAngle)*innerRadius, center.y + cosf(DEG2RAD*nextAngle)*innerRadius);
centralAngle = nextAngle; centralAngle = nextAngle;
} }
rlEnd(); rlEnd();
#endif #endif
rlPopMatrix();
} }
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------

View File

@ -3362,8 +3362,6 @@ void DrawTexturePro(Texture2D texture, Rectangle source, Rectangle dest, Vector2
bottomRight.y = y + (dx + dest.width)*sinRotation + (dy + dest.height)*cosRotation; bottomRight.y = y + (dx + dest.width)*sinRotation + (dy + dest.height)*cosRotation;
} }
rlCheckRenderBatchLimit(4); // Make sure there is enough free space on the batch buffer
rlSetTexture(texture.id); rlSetTexture(texture.id);
rlBegin(RL_QUADS); rlBegin(RL_QUADS);
@ -3494,8 +3492,6 @@ void DrawTextureNPatch(Texture2D texture, NPatchInfo nPatchInfo, Rectangle dest,
coordD.x = (nPatchInfo.source.x + nPatchInfo.source.width)/width; coordD.x = (nPatchInfo.source.x + nPatchInfo.source.width)/width;
coordD.y = (nPatchInfo.source.y + nPatchInfo.source.height)/height; coordD.y = (nPatchInfo.source.y + nPatchInfo.source.height)/height;
rlCheckRenderBatchLimit(9 * 3 * 2); // Maxium number of verts that could happen
rlSetTexture(texture.id); rlSetTexture(texture.id);
rlPushMatrix(); rlPushMatrix();
@ -3639,8 +3635,6 @@ void DrawTextureNPatch(Texture2D texture, NPatchInfo nPatchInfo, Rectangle dest,
// without crossing perimeter, points must be in anticlockwise order // without crossing perimeter, points must be in anticlockwise order
void DrawTexturePoly(Texture2D texture, Vector2 center, Vector2 *points, Vector2 *texcoords, int pointCount, Color tint) void DrawTexturePoly(Texture2D texture, Vector2 center, Vector2 *points, Vector2 *texcoords, int pointCount, Color tint)
{ {
rlCheckRenderBatchLimit((pointCount - 1)*4);
rlSetTexture(texture.id); rlSetTexture(texture.id);
// Texturing is only supported on RL_QUADS // Texturing is only supported on RL_QUADS

View File

@ -160,14 +160,14 @@ void TraceLog(int logType, const char *text, ...)
// Internal memory allocator // Internal memory allocator
// NOTE: Initializes to zero by default // NOTE: Initializes to zero by default
void *MemAlloc(int size) void *MemAlloc(unsigned int size)
{ {
void *ptr = RL_CALLOC(size, 1); void *ptr = RL_CALLOC(size, 1);
return ptr; return ptr;
} }
// Internal memory reallocator // Internal memory reallocator
void *MemRealloc(void *ptr, int size) void *MemRealloc(void *ptr, unsigned int size)
{ {
void *ret = RL_REALLOC(ptr, size); void *ret = RL_REALLOC(ptr, size);
return ret; return ret;