vrheights

annotate 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
rev   line source
nuclear@8 1 #include "material.h"
nuclear@8 2 #include "opengl.h"
nuclear@8 3
nuclear@8 4 Material::Material()
nuclear@8 5 : diffuse(1, 1, 1)
nuclear@8 6 {
nuclear@8 7 alpha = 1.0;
nuclear@8 8 shininess = 60.0;
nuclear@8 9 tex = 0;
nuclear@8 10 }
nuclear@8 11
nuclear@8 12 void Material::setup() const
nuclear@8 13 {
nuclear@8 14 float diff[] = {diffuse.x, diffuse.y, diffuse.z, alpha};
nuclear@8 15 float spec[] = {specular.x, specular.y, specular.z, 1.0};
nuclear@8 16
nuclear@8 17 glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, diff);
nuclear@8 18 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, spec);
nuclear@8 19 glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, shininess > 128.0f ? 128.0f : shininess);
nuclear@8 20
nuclear@8 21 if(tex) {
nuclear@8 22 glEnable(GL_TEXTURE_2D);
nuclear@8 23 glBindTexture(GL_TEXTURE_2D, tex);
nuclear@8 24 } else {
nuclear@8 25 glDisable(GL_TEXTURE_2D);
nuclear@8 26 }
nuclear@8 27 }