From b659c412263f6dd7df962f7d42f4f51b7c3d5609 Mon Sep 17 00:00:00 2001 From: Tomasz Kramkowski Date: Wed, 2 May 2018 21:22:03 +0100 Subject: Implement diffuse texture loading and basic material support --- model.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'model.c') 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]); } } -- cgit v1.2.3-54-g00ecf