summaryrefslogtreecommitdiff
path: root/scene.c
diff options
context:
space:
mode:
authorrodri <rgl@antares-labs.eu>2024-05-12 20:32:05 +0000
committerrodri <rgl@antares-labs.eu>2024-05-12 20:32:05 +0000
commitdc735cec54a148d848932c71e26cd9fbe445e173 (patch)
tree75d3ea4568b4a151fbcae08ba824f129a652044c /scene.c
parent0cd80fe628fc0d8a3672f1fd1d3cfa96c0b0ea2e (diff)
downloadlibgraphics-dc735cec54a148d848932c71e26cd9fbe445e173.tar.gz
libgraphics-dc735cec54a148d848932c71e26cd9fbe445e173.tar.bz2
libgraphics-dc735cec54a148d848932c71e26cd9fbe445e173.zip
add a name property to Material.
Diffstat (limited to 'scene.c')
-rw-r--r--scene.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/scene.c b/scene.c
index 23a546a..15d3cc0 100644
--- a/scene.c
+++ b/scene.c
@@ -154,6 +154,11 @@ loadobjmodel(Model *m, OBJ *obj)
mtl = &m->materials[m->nmaterials-1];
memset(mtl, 0, sizeof *mtl);
+ if(objmtl->name != nil){
+ mtl->name = strdup(objmtl->name);
+ if(mtl->name == nil)
+ sysfatal("strdup: %r");
+ }
mtl->ambient.r = objmtl->Ka.r;
mtl->ambient.g = objmtl->Ka.g;
mtl->ambient.b = objmtl->Ka.b;
@@ -306,8 +311,11 @@ delmodel(Model *m)
freememimage(m->tex);
if(m->nor != nil)
freememimage(m->nor);
- if(m->nmaterials > 0)
+ if(m->nmaterials > 0){
+ while(m->nmaterials--)
+ free(m->materials[m->nmaterials].name);
free(m->materials);
+ }
if(m->nprims > 0)
free(m->prims);
free(m);