vrheights

view src/material.cc @ 8:3f221bdc9bab

mesh loading walk polys
author John Tsiombikas <nuclear@member.fsf.org>
date Fri, 03 Oct 2014 04:16:16 +0300
parents
children
line source
1 #include "material.h"
2 #include "opengl.h"
4 Material::Material()
5 : diffuse(1, 1, 1)
6 {
7 alpha = 1.0;
8 shininess = 60.0;
9 tex = 0;
10 }
12 void Material::setup() const
13 {
14 float diff[] = {diffuse.x, diffuse.y, diffuse.z, alpha};
15 float spec[] = {specular.x, specular.y, specular.z, 1.0};
17 glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, diff);
18 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, spec);
19 glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, shininess > 128.0f ? 128.0f : shininess);
21 if(tex) {
22 glEnable(GL_TEXTURE_2D);
23 glBindTexture(GL_TEXTURE_2D, tex);
24 } else {
25 glDisable(GL_TEXTURE_2D);
26 }
27 }