aboutsummaryrefslogtreecommitdiffstats
path: root/mtl.c
diff options
context:
space:
mode:
Diffstat (limited to 'mtl.c')
-rw-r--r--mtl.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/mtl.c b/mtl.c
index dc74e01..22fc757 100644
--- a/mtl.c
+++ b/mtl.c
@@ -8,13 +8,14 @@
#include "ensize.h"
#include "eprintf.h"
+#include "glprog.h"
#include "mtl.h"
#include "tex.h"
struct mtl {
char name[50];
- GLuint diff;
- GLuint spec;
+#define SH_TEX(_, name) GLuint name;
+#include "shaders/data.h"
};
static struct mtl *mtls;
@@ -50,8 +51,8 @@ int mtl_load(char *name)
snprintf(m->name, sizeof m->name, "%s", name);
- m->diff = tex_file(name, "diff");
- m->spec = tex_file(name, "spec");
+#define SH_TEX(_, n) m->n = tex_file(name, #n);
+#include "shaders/data.h"
return lmtls++;
}
@@ -59,13 +60,14 @@ int mtl_load(char *name)
void mtl_use(int mtl)
{
assert(mtl < lmtls);
+ GLenum texture = GL_TEXTURE0;
// TODO: Blank textures or something
if (mtl < 0)
return;
- gl_tex_active(GL_TEXTURE0);
- gl_tex_bind(GL_TEXTURE_2D, mtls[mtl].diff);
- gl_tex_active(GL_TEXTURE1);
- gl_tex_bind(GL_TEXTURE_2D, mtls[mtl].spec);
+#define SH_TEX(type, name) \
+ gl_tex_active(texture++); \
+ gl_tex_bind(GL_TEXTURE_##type, mtls[mtl].name);
+#include "shaders/data.h"
}