+#include <algorithm>
+#include <string.h>
#include "opengl.h"
#include "material.h"
{
shininess = 0.0f;
alpha = 1.0f;
+ memset(stdtex, 0, sizeof stdtex);
}
void Material::setup() const
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, kd);
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, ks);
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, shininess);
+
+ int ntex = std::min((int)textures.size(), 8); // TODO: use max texture units
+ for(int i=0; i<ntex; i++) {
+ bind_texture(textures[i], i);
+ }
+}
+
+void Material::add_texture(Texture *tex, int type)
+{
+ textures.push_back(tex);
+
+ if(type != MTL_TEX_UNKNOWN) {
+ stdtex[type] = tex;
+ }
}