aboutsummaryrefslogtreecommitdiff
path: root/examples/models
diff options
context:
space:
mode:
authorchriscamacho <chriscamacho@users.noreply.github.com>2019-09-19 16:11:37 +0100
committerRay <raysan5@gmail.com>2019-09-19 17:11:37 +0200
commitbce2dd1231b01964bf619a71d4c9cd2141e41f6b (patch)
tree8ac894101df1f53756982f569a2b22c73213dceb /examples/models
parentd089e1cd34fdae4a17aa589ff20ea0af19b11410 (diff)
downloadraylib-bce2dd1231b01964bf619a71d4c9cd2141e41f6b.tar.gz
raylib-bce2dd1231b01964bf619a71d4c9cd2141e41f6b.zip
fixed leak with PBR example (#971)
Diffstat (limited to 'examples/models')
-rw-r--r--examples/models/models_material_pbr.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/examples/models/models_material_pbr.c b/examples/models/models_material_pbr.c
index 8702f79a..2c0a15e3 100644
--- a/examples/models/models_material_pbr.c
+++ b/examples/models/models_material_pbr.c
@@ -50,6 +50,7 @@ int main(void)
// NOTE: New VBO for tangents is generated at default location and also binded to mesh VAO
MeshTangents(&model.meshes[0]);
+ UnloadMaterial(model.materials[0]); // get rid of default material
model.materials[0] = LoadMaterialPBR((Color){ 255, 255, 255, 255 }, 1.0f, 1.0f);
// Create lights
@@ -98,7 +99,19 @@ int main(void)
// De-Initialization
//--------------------------------------------------------------------------------------
- UnloadMaterial(model.materials[0]); // Unload material: shader and textures
+
+ // user must unload shaders and textures as they could be in use
+ // by other models....
+ UnloadShader(model.materials[0].shader);
+ UnloadTexture(model.materials[0].maps[MAP_ALBEDO].texture);
+ UnloadTexture(model.materials[0].maps[MAP_NORMAL].texture);
+ UnloadTexture(model.materials[0].maps[MAP_METALNESS].texture);
+ UnloadTexture(model.materials[0].maps[MAP_ROUGHNESS].texture);
+ UnloadTexture(model.materials[0].maps[MAP_OCCLUSION].texture);
+ UnloadTexture(model.materials[0].maps[MAP_IRRADIANCE].texture);
+ UnloadTexture(model.materials[0].maps[MAP_PREFILTER].texture);
+ UnloadTexture(model.materials[0].maps[MAP_BRDF].texture);
+
UnloadModel(model); // Unload model
CloseWindow(); // Close window and OpenGL context