]> git.tdb.fi Git - libs/gl.git/blob - source/material.cpp
Make Material::apply const
[libs/gl.git] / source / material.cpp
1 /* $Id$
2
3 This file is part of libmspgl
4 Copyright © 2007  Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
6 */
7
8 #include "material.h"
9
10 namespace Msp {
11 namespace GL {
12
13 Material::Material():
14         ambient(0.2),
15         diffuse(0.8),
16         specular(0),
17         emission(0),
18         shininess(0)
19 { }
20
21 void Material::set_ambient(const Color &a)
22 {
23         ambient=a;
24 }
25
26 void Material::set_diffuse(const Color &d)
27 {
28         diffuse=d;
29 }
30
31 void Material::set_specular(const Color &s)
32 {
33         specular=s;
34 }
35
36 void Material::set_emission(const Color &e)
37 {
38         emission=e;
39 }
40
41 void Material::set_shininess(float s)
42 {
43         shininess=s;
44 }
45
46 void Material::apply() const
47 {
48         glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, &ambient.r);
49         glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, &diffuse.r);
50         glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, &specular.r);
51         glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, &emission.r);
52         glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, shininess);
53 }
54
55 } // namespace GL
56 } // namespace Msp