Working on batch reset issue
Corrected memory leak!
This commit is contained in:
parent
eef44fd930
commit
4c84208644
33
src/rlgl.h
33
src/rlgl.h
@ -822,11 +822,11 @@ static DynamicBuffer triangles; // Default dynamic buffer for triang
|
||||
static DynamicBuffer quads; // Default dynamic buffer for quads data (used to draw textures)
|
||||
|
||||
// Default buffers draw calls
|
||||
static DrawCall *draws;
|
||||
static int drawsCounter;
|
||||
static DrawCall *draws = NULL;
|
||||
static int drawsCounter = 0;
|
||||
|
||||
// Temp vertex buffer to be used with rlTranslate, rlRotate, rlScale
|
||||
static Vector3 *tempBuffer;
|
||||
static Vector3 *tempBuffer = NULL;
|
||||
static int tempBufferCount = 0;
|
||||
static bool useTempBuffer = false;
|
||||
|
||||
@ -1211,21 +1211,28 @@ void rlEnd(void)
|
||||
|
||||
// Verify internal buffers limits
|
||||
// NOTE: This check is combined with usage of rlCheckBufferLimit()
|
||||
if ((lines.vCounter/2 >= MAX_LINES_BATCH - 2) ||
|
||||
(triangles.vCounter/3 >= MAX_TRIANGLES_BATCH - 3) ||
|
||||
(quads.vCounter/4 >= MAX_QUADS_BATCH - 4)) rlglDraw();
|
||||
if ((lines.vCounter/2 >= (MAX_LINES_BATCH - 2)) ||
|
||||
(triangles.vCounter/3 >= (MAX_TRIANGLES_BATCH - 3)) ||
|
||||
(quads.vCounter/4 >= (MAX_QUADS_BATCH - 4)))
|
||||
{
|
||||
TraceLog(LOG_INFO, "Max batch limit reached. Forcing draw call launch.");
|
||||
rlglDraw();
|
||||
}
|
||||
}
|
||||
|
||||
// Define one vertex (position)
|
||||
void rlVertex3f(float x, float y, float z)
|
||||
{
|
||||
if (useTempBuffer)
|
||||
{
|
||||
if (tempBufferCount < TEMP_VERTEX_BUFFER_SIZE)
|
||||
{
|
||||
tempBuffer[tempBufferCount].x = x;
|
||||
tempBuffer[tempBufferCount].y = y;
|
||||
tempBuffer[tempBufferCount].z = z;
|
||||
tempBufferCount++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (currentDrawMode)
|
||||
@ -1828,6 +1835,7 @@ void rlglClose(void)
|
||||
TraceLog(LOG_INFO, "[TEX ID %i] Unloaded texture data (base white texture) from VRAM", whiteTexture);
|
||||
|
||||
free(draws);
|
||||
free(tempBuffer);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -4309,11 +4317,6 @@ static void DrawBuffersDefault(void)
|
||||
glUseProgram(0); // Unbind shader program
|
||||
}
|
||||
|
||||
// Reset draws counter
|
||||
drawsCounter = 1;
|
||||
draws[0].textureId = whiteTexture;
|
||||
draws[0].vertexCount = 0;
|
||||
|
||||
// Reset vertex counters for next frame
|
||||
lines.vCounter = 0;
|
||||
lines.cCounter = 0;
|
||||
@ -4323,12 +4326,20 @@ static void DrawBuffersDefault(void)
|
||||
quads.tcCounter = 0;
|
||||
quads.cCounter = 0;
|
||||
|
||||
tempBufferCount = 0;
|
||||
useTempBuffer = false;
|
||||
|
||||
// Reset depth for next draw
|
||||
currentDepth = -1.0f;
|
||||
|
||||
// Restore projection/modelview matrices
|
||||
projection = matProjection;
|
||||
modelview = matModelView;
|
||||
|
||||
// Reset draws counter
|
||||
drawsCounter = 1;
|
||||
draws[0].textureId = whiteTexture;
|
||||
draws[0].vertexCount = 0;
|
||||
}
|
||||
|
||||
// Unload default internal buffers vertex data from CPU and GPU
|
||||
|
Loading…
Reference in New Issue
Block a user