eqemu

diff src/material.cc @ 3:f9274bebe55e

adding 3d graphics stuff
author John Tsiombikas <nuclear@member.fsf.org>
date Thu, 17 Jul 2014 02:35:19 +0300
parents
children 3d3656360a82
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/material.cc	Thu Jul 17 02:35:19 2014 +0300
     1.3 @@ -0,0 +1,20 @@
     1.4 +#include <GL/glew.h>
     1.5 +#include "material.h"
     1.6 +
     1.7 +Material::Material()
     1.8 +	: color(1, 1, 1), specular(0, 0, 0)
     1.9 +{
    1.10 +	shininess = 1.0;
    1.11 +	alpha = 1.0;
    1.12 +}
    1.13 +
    1.14 +void Material::setup() const
    1.15 +{
    1.16 +	float col[] = {color.x, color.y, color.z, alpha};
    1.17 +	glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, col);
    1.18 +
    1.19 +	float spec[] = {specular.x, specular.y, specular.z, 1.0};
    1.20 +	glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, spec);
    1.21 +
    1.22 +	glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, shininess > 128 ? 128 : shininess);
    1.23 +}