aboutsummaryrefslogtreecommitdiffstats
path: root/model.c
diff options
context:
space:
mode:
Diffstat (limited to 'model.c')
-rw-r--r--model.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/model.c b/model.c
index 7a6a256..88931c0 100644
--- a/model.c
+++ b/model.c
@@ -44,7 +44,10 @@ void model_load(struct model *mdl, const struct fmd *fmd)
for (int i = 0; i < fmd->nmeshes; i++) {
struct mesh *m = &mdl->meshes[i];
struct fmd_mesh *fm = &fmd->meshes[i];
- m->mtl = NULL;
+ if (fm->midx >= 0)
+ m->mtl = mtl_load(fmd->mtls[fm->midx]);
+ else
+ m->mtl = -1;
m->elems.idx = fm->tidx * NELEM(*fmd->tris);
m->elems.cnt = fm->tcnt * NELEM(*fmd->tris);
}
@@ -55,6 +58,7 @@ void model_render(struct model *mdl)
gl_va_bind(mdl->vao);
for (int i = 0; i < mdl->nmeshes; i++) {
struct mesh *m = &mdl->meshes[i];
+ mtl_use(m->mtl);
gl_draw_elems(GL_TRIANGLES, m->elems.cnt, GL_UNSIGNED_INT, &((GLuint *)NULL)[m->elems.idx]);
}
}