]> git.tdb.fi Git - libs/gl.git/blob - source/material.h
fa1612e142d1dca596fe58a59e03491d74b0fc70
[libs/gl.git] / source / material.h
1 /* $Id$
2
3 This file is part of libmspgl
4 Copyright © 2007-2008  Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
6 */
7
8 #ifndef MSP_GL_MATERIAL_H_
9 #define MSP_GL_MATERIAL_H_
10
11 #include <msp/datafile/objectloader.h>
12 #include "bindable.h"
13 #include "color.h"
14
15 namespace Msp {
16 namespace GL {
17
18 /**
19 Stores OpenGL material properties.  Since OpenGL does not support material
20 objects, application of material is done with several calls to glMaterial.
21 */
22 class Material: public Bindable<Material>
23 {
24 public:
25         class Loader: public DataFile::ObjectLoader<Material>
26         {
27         public:
28                 Loader(Material &);
29         
30         private:
31                 void ambient(float, float, float, float);
32                 void diffuse(float, float, float, float);
33                 void specular(float, float, float, float);
34                 void emission(float, float, float, float);
35         };
36
37 private:
38         Color ambient;
39         Color diffuse;
40         Color specular;
41         Color emission;
42         float shininess;
43
44 public:
45         Material();
46         void set_ambient(const Color &a);
47         void set_diffuse(const Color &d);
48         void set_specular(const Color &s);
49         void set_emission(const Color &e);
50         void set_shininess(float s);
51         const Color &get_ambient() const { return ambient; }
52         const Color &get_diffuse() const { return diffuse; }
53         const Color &get_specular() const { return specular; }
54         const Color &get_emission() const { return emission; }
55         float get_shininess() const { return shininess; }
56         void bind() const;
57
58         static void unbind();
59 };
60
61 } // namespace GL
62 } // namespace Msp
63
64 #endif