Reviewed unloading model data
When UnloadModel() --> UnloadMaterial(), avoid unloading default shader (if used) and avoid unlaoding default texture (if used), that data is managed by raylib internally. The question is... should UnloadModel() also UnloadMaterial()?
This commit is contained in:
parent
cd5e2e0f17
commit
6d64327a87
1 changed files with 4 additions and 5 deletions
|
@ -1671,14 +1671,13 @@ Material LoadMaterialDefault(void)
|
||||||
// Unload material from memory
|
// Unload material from memory
|
||||||
void UnloadMaterial(Material material)
|
void UnloadMaterial(Material material)
|
||||||
{
|
{
|
||||||
// Unload material shader
|
// Unload material shader (avoid unloading default shader, managed by raylib)
|
||||||
UnloadShader(material.shader);
|
if (material.shader.id != GetShaderDefault().id) UnloadShader(material.shader);
|
||||||
|
|
||||||
// Unload loaded texture maps
|
// Unload loaded texture maps (avoid unloading default texture, managed by raylib)
|
||||||
for (int i = 0; i < MAX_MATERIAL_MAPS; i++)
|
for (int i = 0; i < MAX_MATERIAL_MAPS; i++)
|
||||||
{
|
{
|
||||||
// NOTE: We already check for (tex.id > 0) inside function
|
if (material.maps[i].texture.id != GetTextureDefault().id) rlDeleteTextures(material.maps[i].texture.id);
|
||||||
rlDeleteTextures(material.maps[i].texture.id);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue