UnloadMaterial can also optionally free textures and shader.

This commit is contained in:
jussi
2024-09-25 20:54:32 +03:00
parent cd6471d339
commit 45e11be96a
10 changed files with 42 additions and 33 deletions

View File

@@ -605,7 +605,7 @@ int lmodelsIsModelReady( lua_State* L ) {
/*
> RL.UnloadModel( Model model )
Unload model (including meshes) from memory (RAM and/or VRAM)
Unload model (meshes/materials) from memory (RAM and/or VRAM)
*/
int lmodelsUnloadModel( lua_State* L ) {
Model* model = uluaGetModel( L, 1 );
@@ -1951,19 +1951,23 @@ int lmodelsIsMaterialReady( lua_State* L ) {
}
/*
> RL.UnloadMaterial( Material material )
> RL.UnloadMaterial( Material material, bool freeAll )
Unload material from GPU memory (VRAM)
Unload material from GPU memory (VRAM). Note! Use freeAll to unload shaders and textures
*/
int lmodelsUnloadMaterial( lua_State* L ) {
Material* material = uluaGetMaterial( L, 1 );
bool freeAll = lua_toboolean( L, 2 );
/* Custom UnloadMaterial since we don't want to free Shaders or Textures. */
unloadMaterial( material );
if ( freeAll ) {
UnloadMaterial( *material );
}
/* Custom UnloadMaterial if we don't want to free Shaders or Textures. */
else {
unloadMaterial( material );
}
memset( material, 0, sizeof( Material ) );
// UnloadMaterial( *material );
return 0;
}