aboutsummaryrefslogtreecommitdiffstats
path: root/model.c
diff options
context:
space:
mode:
authorTomasz Kramkowski <tk@the-tk.com>2018-05-02 21:22:03 +0100
committerTomasz Kramkowski <tk@the-tk.com>2018-05-02 21:22:03 +0100
commitb659c412263f6dd7df962f7d42f4f51b7c3d5609 (patch)
treee2495e0b1446527b909a9c9fa2776797c7c28221 /model.c
parentec93a8eddf70adef2b1439a511d990021ad25d99 (diff)
downloadfaqe-b659c412263f6dd7df962f7d42f4f51b7c3d5609.tar.gz
faqe-b659c412263f6dd7df962f7d42f4f51b7c3d5609.tar.xz
faqe-b659c412263f6dd7df962f7d42f4f51b7c3d5609.zip
Implement diffuse texture loading and basic material support
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]);
}
}