]> git.tdb.fi Git - libs/gl.git/blob - source/materials/basicmaterial.h
Check the flat qualifier from the correct member
[libs/gl.git] / source / materials / 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 /**
10 A basic and cheap material using the Phong shading model.  Results are roughly
11 equivalent to legacy OpenGL materials.
12
13 In addition to the usual properties of the Phong shading model, normal mapping
14 and reflections are supported.  Reflections require an EnvironmentMap effect.
15 */
16 class BasicMaterial: public Material
17 {
18 public:
19         class Loader: public DataFile::DerivedObjectLoader<BasicMaterial, Material::PropertyLoader<BasicMaterial> >
20         {
21         private:
22                 static ActionMap shared_actions;
23
24         public:
25                 Loader(BasicMaterial &, Collection &);
26
27         private:
28                 virtual void init_actions();
29         };
30
31 private:
32         Property<Color> diffuse;
33         Property<Color> specular;
34         Property<float> shininess;
35         Property<Vector3> normal;
36         Property<Color> emission;
37         Property<float> reflectivity;
38
39         static const Tag texture_tags[];
40
41 public:
42         BasicMaterial();
43
44 protected:
45         virtual void fill_program_info(std::string &, std::map<std::string, int> &) const;
46
47 public:
48         virtual const Tag *get_texture_tags() const { return texture_tags; }
49         virtual const Texture *get_texture(Tag) const;
50
51         void set_diffuse(const Color &);
52         void set_diffuse_map(const Texture *);
53         void set_specular(const Color &);
54         void set_specular_map(const Texture *);
55         void set_normal_map(const Texture *);
56         void set_emission(const Color &);
57         void set_emission_map(const Texture *);
58         void set_shininess(float);
59         void set_shininess_map(const Texture *);
60         void set_reflectivity(float);
61         void set_reflectivity_map(const Texture *);
62 };
63
64 } // namespace GL
65 } // namespace Msp
66
67 #endif