REVIEWED: rlUnloadMesh() #1615
This commit is contained in:
parent
742206c1f2
commit
2ff5fa73e9
2 changed files with 7 additions and 6 deletions
|
@ -859,7 +859,7 @@ void UploadMesh(Mesh *mesh)
|
||||||
void UnloadMesh(Mesh mesh)
|
void UnloadMesh(Mesh mesh)
|
||||||
{
|
{
|
||||||
// Unload rlgl mesh vboId data
|
// Unload rlgl mesh vboId data
|
||||||
rlUnloadMesh(mesh);
|
rlUnloadMesh(&mesh);
|
||||||
|
|
||||||
RL_FREE(mesh.vertices);
|
RL_FREE(mesh.vertices);
|
||||||
RL_FREE(mesh.texcoords);
|
RL_FREE(mesh.texcoords);
|
||||||
|
|
11
src/rlgl.h
11
src/rlgl.h
|
@ -575,7 +575,7 @@ RLAPI void rlUpdateMesh(Mesh mesh, int buffer, int count); // Upd
|
||||||
RLAPI void rlUpdateMeshAt(Mesh mesh, int buffer, int count, int index); // Update vertex or index data on GPU, at index
|
RLAPI void rlUpdateMeshAt(Mesh mesh, int buffer, int count, int index); // Update vertex or index data on GPU, at index
|
||||||
RLAPI void rlDrawMesh(Mesh mesh, Material material, Matrix transform); // Draw a 3d mesh with material and transform
|
RLAPI void rlDrawMesh(Mesh mesh, Material material, Matrix transform); // Draw a 3d mesh with material and transform
|
||||||
RLAPI void rlDrawMeshInstanced(Mesh mesh, Material material, Matrix *transforms, int count); // Draw a 3d mesh with material and transform
|
RLAPI void rlDrawMeshInstanced(Mesh mesh, Material material, Matrix *transforms, int count); // Draw a 3d mesh with material and transform
|
||||||
RLAPI void rlUnloadMesh(Mesh mesh); // Unload mesh data from CPU and GPU
|
RLAPI void rlUnloadMesh(Mesh *mesh); // Unload mesh data from CPU and GPU
|
||||||
|
|
||||||
// NOTE: There is a set of shader related functions that are available to end user,
|
// NOTE: There is a set of shader related functions that are available to end user,
|
||||||
// to avoid creating function wrappers through core module, they have been directly declared in raylib.h
|
// to avoid creating function wrappers through core module, they have been directly declared in raylib.h
|
||||||
|
@ -3012,20 +3012,21 @@ void rlDrawMeshInstanced(Mesh mesh, Material material, Matrix *transforms, int c
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unload mesh data from CPU and GPU
|
// Unload mesh data from CPU and GPU
|
||||||
void rlUnloadMesh(Mesh mesh)
|
void rlUnloadMesh(Mesh *mesh)
|
||||||
{
|
{
|
||||||
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
|
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
|
||||||
for (int i = 0; i < 7; i++) glDeleteBuffers(1, &mesh.vboId[i]); // DEFAULT_MESH_VERTEX_BUFFERS (model.c)
|
for (int i = 0; i < 7; i++) glDeleteBuffers(1, mesh->vboId[i]); // DEFAULT_MESH_VERTEX_BUFFERS (model.c)
|
||||||
if (RLGL.ExtSupported.vao)
|
if (RLGL.ExtSupported.vao)
|
||||||
{
|
{
|
||||||
glBindVertexArray(0);
|
glBindVertexArray(0);
|
||||||
glDeleteVertexArrays(1, &mesh.vaoId);
|
glDeleteVertexArrays(1, mesh->vaoId);
|
||||||
TRACELOG(LOG_INFO, "VAO: [ID %i] Unloaded vertex data from VRAM (GPU)", mesh.vaoId);
|
TRACELOG(LOG_INFO, "VAO: [ID %i] Unloaded vertex data from VRAM (GPU)", mesh.vaoId);
|
||||||
}
|
}
|
||||||
else TRACELOG(LOG_INFO, "VBO: Unloaded vertex data from VRAM (GPU)");
|
else TRACELOG(LOG_INFO, "VBO: Unloaded vertex data from VRAM (GPU)");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
RL_FREE(mesh.vboId);
|
RL_FREE(mesh->vboId);
|
||||||
|
mesh->vboId = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read screen pixel data (color buffer)
|
// Read screen pixel data (color buffer)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue