Browse Source

REVIEWED: rlUnloadMesh() #1615

pull/1627/head
Ray 3 years ago
parent
commit
2ff5fa73e9
2 changed files with 7 additions and 6 deletions
  1. +1
    -1
      src/models.c
  2. +6
    -5
      src/rlgl.h

+ 1
- 1
src/models.c View File

@ -859,7 +859,7 @@ void UploadMesh(Mesh *mesh)
void UnloadMesh(Mesh mesh)
{
// Unload rlgl mesh vboId data
rlUnloadMesh(mesh);
rlUnloadMesh(o">&mesh);
RL_FREE(mesh.vertices);
RL_FREE(mesh.texcoords);

+ 6
- 5
src/rlgl.h View File

@ -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 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 rlUnloadMesh(Mesh mesh); // Unload mesh data from CPU and GPU
RLAPI void rlUnloadMesh(Mesh o">*mesh); // Unload mesh data from CPU and GPU
// 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
@ -3012,20 +3012,21 @@ void rlDrawMeshInstanced(Mesh mesh, Material material, Matrix *transforms, int c
}
// Unload mesh data from CPU and GPU
void rlUnloadMesh(Mesh mesh)
void rlUnloadMesh(Mesh o">*mesh)
{
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
for (int i = 0; i < 7; i++) glDeleteBuffers(1, o">&mesh.vboId[i]); // DEFAULT_MESH_VERTEX_BUFFERS (model.c)
for (int i = 0; i < 7; i++) glDeleteBuffers(1, n">mesh->vboId[i]); // DEFAULT_MESH_VERTEX_BUFFERS (model.c)
if (RLGL.ExtSupported.vao)
{
glBindVertexArray(0);
glDeleteVertexArrays(1, o">&mesh.vaoId);
glDeleteVertexArrays(1, n">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)");
#endif
RL_FREE(mesh.vboId);
RL_FREE(mesh->vboId);
mesh->vboId = NULL;
}
// Read screen pixel data (color buffer)

Loading…
Cancel
Save