]> git.tdb.fi Git - libs/gl.git/blob - source/materials/unlitmaterial.cpp
Check the flat qualifier from the correct member
[libs/gl.git] / source / materials / unlitmaterial.cpp
1 #include "unlitmaterial.h"
2
3 using namespace std;
4
5 namespace Msp {
6 namespace GL {
7
8 const Tag UnlitMaterial::texture_tags[] =
9 {
10         Tag("color_tex"),
11         Tag()
12 };
13
14 UnlitMaterial::UnlitMaterial()
15 {
16         set_color(Color(1.0f));
17 }
18
19 void UnlitMaterial::fill_program_info(string &module_name, map<string, int> &spec_values) const
20 {
21         module_name = "unlit.glsl";
22         spec_values["use_texture"] = (texture!=0);
23         spec_values["use_vertex_color"] = vertex_color;
24 }
25
26 const Texture *UnlitMaterial::get_texture(Tag tag) const
27 {
28         if(tag==texture_tags[0])
29                 return texture;
30         else
31                 return 0;
32 }
33
34 void UnlitMaterial::set_texture(const Texture *tex)
35 {
36         texture = tex;
37 }
38
39 void UnlitMaterial::set_color(const Color &c)
40 {
41         color = c;
42         shdata.uniform("unlit_material.color", color);
43 }
44
45 void UnlitMaterial::set_vertex_color(bool vc)
46 {
47         vertex_color = vc;
48 }
49
50
51 DataFile::Loader::ActionMap UnlitMaterial::Loader::shared_actions;
52
53 UnlitMaterial::Loader::Loader(UnlitMaterial &m, Collection &c):
54         DerivedObjectLoader<UnlitMaterial, Material::PropertyLoader<UnlitMaterial> >(m, c)
55 {
56         set_actions(shared_actions);
57 }
58
59 void UnlitMaterial::Loader::init_actions()
60 {
61         Material::PropertyLoader<UnlitMaterial>::init_actions();
62         add("texture", &Loader::property_texture, &UnlitMaterial::set_texture);
63         add_property("color", &UnlitMaterial::set_color, 0, true);
64         add("vertex_color", &UnlitMaterial::vertex_color);
65 }
66
67 } // namespace GL
68 } // namespace Msp