Working on batch reset issue
Corrected memory leak!
This commit is contained in:
parent
eef44fd930
commit
4c84208644
45
src/rlgl.h
45
src/rlgl.h
@ -562,7 +562,7 @@ int GetPixelDataSize(int width, int height, int format);// Get pixel data size i
|
|||||||
#define WINGDIAPI __declspec(dllimport)
|
#define WINGDIAPI __declspec(dllimport)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <GL/gl.h> // OpenGL 1.1 library
|
#include <GL/gl.h> // OpenGL 1.1 library
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -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)
|
static DynamicBuffer quads; // Default dynamic buffer for quads data (used to draw textures)
|
||||||
|
|
||||||
// Default buffers draw calls
|
// Default buffers draw calls
|
||||||
static DrawCall *draws;
|
static DrawCall *draws = NULL;
|
||||||
static int drawsCounter;
|
static int drawsCounter = 0;
|
||||||
|
|
||||||
// Temp vertex buffer to be used with rlTranslate, rlRotate, rlScale
|
// Temp vertex buffer to be used with rlTranslate, rlRotate, rlScale
|
||||||
static Vector3 *tempBuffer;
|
static Vector3 *tempBuffer = NULL;
|
||||||
static int tempBufferCount = 0;
|
static int tempBufferCount = 0;
|
||||||
static bool useTempBuffer = false;
|
static bool useTempBuffer = false;
|
||||||
|
|
||||||
@ -1211,9 +1211,13 @@ void rlEnd(void)
|
|||||||
|
|
||||||
// Verify internal buffers limits
|
// Verify internal buffers limits
|
||||||
// NOTE: This check is combined with usage of rlCheckBufferLimit()
|
// NOTE: This check is combined with usage of rlCheckBufferLimit()
|
||||||
if ((lines.vCounter/2 >= MAX_LINES_BATCH - 2) ||
|
if ((lines.vCounter/2 >= (MAX_LINES_BATCH - 2)) ||
|
||||||
(triangles.vCounter/3 >= MAX_TRIANGLES_BATCH - 3) ||
|
(triangles.vCounter/3 >= (MAX_TRIANGLES_BATCH - 3)) ||
|
||||||
(quads.vCounter/4 >= MAX_QUADS_BATCH - 4)) rlglDraw();
|
(quads.vCounter/4 >= (MAX_QUADS_BATCH - 4)))
|
||||||
|
{
|
||||||
|
TraceLog(LOG_INFO, "Max batch limit reached. Forcing draw call launch.");
|
||||||
|
rlglDraw();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Define one vertex (position)
|
// Define one vertex (position)
|
||||||
@ -1221,10 +1225,13 @@ void rlVertex3f(float x, float y, float z)
|
|||||||
{
|
{
|
||||||
if (useTempBuffer)
|
if (useTempBuffer)
|
||||||
{
|
{
|
||||||
tempBuffer[tempBufferCount].x = x;
|
if (tempBufferCount < TEMP_VERTEX_BUFFER_SIZE)
|
||||||
tempBuffer[tempBufferCount].y = y;
|
{
|
||||||
tempBuffer[tempBufferCount].z = z;
|
tempBuffer[tempBufferCount].x = x;
|
||||||
tempBufferCount++;
|
tempBuffer[tempBufferCount].y = y;
|
||||||
|
tempBuffer[tempBufferCount].z = z;
|
||||||
|
tempBufferCount++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1828,6 +1835,7 @@ void rlglClose(void)
|
|||||||
TraceLog(LOG_INFO, "[TEX ID %i] Unloaded texture data (base white texture) from VRAM", whiteTexture);
|
TraceLog(LOG_INFO, "[TEX ID %i] Unloaded texture data (base white texture) from VRAM", whiteTexture);
|
||||||
|
|
||||||
free(draws);
|
free(draws);
|
||||||
|
free(tempBuffer);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2732,7 +2740,7 @@ void *rlReadTexturePixels(Texture2D texture)
|
|||||||
glPixelStorei(GL_PACK_ALIGNMENT, 1);
|
glPixelStorei(GL_PACK_ALIGNMENT, 1);
|
||||||
|
|
||||||
int glInternalFormat, glFormat, glType;
|
int glInternalFormat, glFormat, glType;
|
||||||
GetGlFormats(texture.format, &glInternalFormat, &glFormat, &glType);
|
GetGlFormats(texture.format, &glInternalFormat, &glFormat, &glType);
|
||||||
unsigned int size = GetPixelDataSize(texture.width, texture.height, texture.format);
|
unsigned int size = GetPixelDataSize(texture.width, texture.height, texture.format);
|
||||||
|
|
||||||
if ((glInternalFormat != -1) && (texture.format < COMPRESSED_DXT1_RGB))
|
if ((glInternalFormat != -1) && (texture.format < COMPRESSED_DXT1_RGB))
|
||||||
@ -4309,11 +4317,6 @@ static void DrawBuffersDefault(void)
|
|||||||
glUseProgram(0); // Unbind shader program
|
glUseProgram(0); // Unbind shader program
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset draws counter
|
|
||||||
drawsCounter = 1;
|
|
||||||
draws[0].textureId = whiteTexture;
|
|
||||||
draws[0].vertexCount = 0;
|
|
||||||
|
|
||||||
// Reset vertex counters for next frame
|
// Reset vertex counters for next frame
|
||||||
lines.vCounter = 0;
|
lines.vCounter = 0;
|
||||||
lines.cCounter = 0;
|
lines.cCounter = 0;
|
||||||
@ -4323,12 +4326,20 @@ static void DrawBuffersDefault(void)
|
|||||||
quads.tcCounter = 0;
|
quads.tcCounter = 0;
|
||||||
quads.cCounter = 0;
|
quads.cCounter = 0;
|
||||||
|
|
||||||
|
tempBufferCount = 0;
|
||||||
|
useTempBuffer = false;
|
||||||
|
|
||||||
// Reset depth for next draw
|
// Reset depth for next draw
|
||||||
currentDepth = -1.0f;
|
currentDepth = -1.0f;
|
||||||
|
|
||||||
// Restore projection/modelview matrices
|
// Restore projection/modelview matrices
|
||||||
projection = matProjection;
|
projection = matProjection;
|
||||||
modelview = matModelView;
|
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
|
// Unload default internal buffers vertex data from CPU and GPU
|
||||||
|
Loading…
Reference in New Issue
Block a user