]> git.tdb.fi Git - libs/gl.git/blob - source/basicmaterial.h
Give materials the capability to automatically create a suitable shader
[libs/gl.git] / source / basicmaterial.h
1 #ifndef MSP_GL_BASICMATERIAL_H_
2 #define MSP_GL_BASICMATERIAL_H_
3
4 #include "material.h"
5
6 namespace Msp {
7 namespace GL {
8
9 class BasicMaterial: public Material
10 {
11 public:
12         class Loader: public DataFile::DerivedObjectLoader<BasicMaterial, Material::LoaderBase<BasicMaterial> >
13         {
14         private:
15                 static ActionMap shared_actions;
16
17         public:
18                 Loader(BasicMaterial &);
19                 Loader(BasicMaterial &, Collection &);
20
21         private:
22                 virtual void init_actions();
23         };
24
25 private:
26         Property<Color> diffuse;
27         Property<Color> specular;
28         Property<float> shininess;
29         Property<Vector3> normal;
30         Property<Color> emission;
31         Property<float> reflectivity;
32
33 public:
34         BasicMaterial();
35
36 protected:
37         virtual std::string create_program_source() const;
38
39 public:
40         void attach_textures_to(Texturing &, ProgramData &) const;
41
42         void set_diffuse(const Color &);
43         void set_diffuse_map(const Texture *);
44         void set_specular(const Color &);
45         void set_specular_map(const Texture *);
46         void set_normal_map(const Texture *);
47         void set_emission(const Color &);
48         void set_emission_map(const Texture *);
49         void set_shininess(float);
50         void set_shininess_map(const Texture *);
51         void set_reflectivity(float);
52         void set_reflectivity_map(const Texture *);
53 };
54
55 } // namespace GL
56 } // namespace Msp
57
58 #endif