Corrected bug and comments on model unloading

This commit is contained in:
raysan5 2016-03-27 18:33:30 +02:00
parent 8b7ca8b670
commit 956a6e6f77
2 changed files with 11 additions and 12 deletions

View File

@ -608,6 +608,8 @@ void UnloadModel(Model model)
//if (model.mesh.texcoords2 != NULL) free(model.mesh.texcoords2); // Not used
//if (model.mesh.tangents != NULL) free(model.mesh.tangents); // Not used
TraceLog(INFO, "Unloaded model data from RAM (CPU)");
rlDeleteBuffers(model.mesh.vboId[0]); // vertex
rlDeleteBuffers(model.mesh.vboId[1]); // texcoords
rlDeleteBuffers(model.mesh.vboId[2]); // normals
@ -616,9 +618,6 @@ void UnloadModel(Model model)
//rlDeleteBuffers(model.mesh.vboId[5]); // colors (NOT USED)
rlDeleteVertexArrays(model.mesh.vaoId);
if (model.mesh.vaoId > 0) TraceLog(INFO, "[VAO ID %i] Unloaded model data from VRAM (GPU)", model.mesh.vaoId);
else TraceLog(INFO, "[VBO ID %i][VBO ID %i][VBO ID %i] Unloaded model data from VRAM (GPU)", model.mesh.vboId[0], model.mesh.vboId[1], model.mesh.vboId[2]);
}
// Link a texture to a model

View File

@ -823,7 +823,11 @@ void rlDeleteShader(unsigned int id)
void rlDeleteVertexArrays(unsigned int id)
{
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
if (vaoSupported) glDeleteVertexArrays(1, &id);
if (vaoSupported)
{
glDeleteVertexArrays(1, &id);
TraceLog(INFO, "[VAO ID %i] Unloaded model data from VRAM (GPU)", id);
}
#endif
}
@ -832,6 +836,8 @@ void rlDeleteBuffers(unsigned int id)
{
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
glDeleteBuffers(1, &id);
if (!vaoSupported) TraceLog(INFO, "[VBO ID %i] Unloaded model vertex data from VRAM (GPU)", id);
#endif
}
@ -1238,12 +1244,6 @@ void rlglClose(void)
rlglUnloadFBO(postproFbo);
// Unload postpro quad model data
#if defined(GRAPHICS_API_OPENGL_11)
free(postproQuad.mesh.vertices);
free(postproQuad.mesh.texcoords);
free(postproQuad.mesh.normals);
#endif
rlDeleteBuffers(postproQuad.mesh.vboId[0]);
rlDeleteBuffers(postproQuad.mesh.vboId[1]);
rlDeleteBuffers(postproQuad.mesh.vboId[2]);
@ -1907,7 +1907,7 @@ void rlglGenerateMipmaps(Texture2D texture)
TraceLog(WARNING, "[TEX ID %i] Mipmaps generated manually on CPU side", texture.id);
// NOTE: Once mipmaps have been generated and data has been uploaded to GPU VRAM, we can discard RAM data
free(data):
free(data);
#elif defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
glGenerateMipmap(GL_TEXTURE_2D); // Generate mipmaps automatically