9 : diffuse(1.0f, 1.0f, 1.0f)
13 memset(stdtex, 0, sizeof stdtex);
16 void Material::setup() const
18 float kd[] = {diffuse.x, diffuse.y, diffuse.z, alpha};
19 float ks[] = {specular.x, specular.y, specular.z, 1.0f};
21 glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, kd);
22 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, ks);
23 glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, shininess);
25 int ntex = std::min((int)textures.size(), 8); // TODO: use max texture units
26 for(int i=0; i<ntex; i++) {
27 bind_texture(textures[i], i);
30 if(stdtex[MTL_TEX_LIGHTMAP]) {
31 bind_program(stdtex[MTL_TEX_DIFFUSE] ? sdr_ltmap : sdr_ltmap_notex);
35 void Material::add_texture(Texture *tex, int type)
37 textures.push_back(tex);
39 if(type != MTL_TEX_UNKNOWN) {