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