]> git.tdb.fi Git - libs/gl.git/blobdiff - source/materials/unlitmaterial.cpp
Check the flat qualifier from the correct member
[libs/gl.git] / source / materials / unlitmaterial.cpp
index 5eddd66997416438643003dd5efdc872a25ebbec..e1979051672481f277b953253589e88925c23716 100644 (file)
@@ -5,26 +5,30 @@ using namespace std;
 namespace Msp {
 namespace GL {
 
-UnlitMaterial::UnlitMaterial():
-       texture(0),
-       vertex_color(false)
+const Tag UnlitMaterial::texture_tags[] =
 {
-       set_tint(Color(1.0f));
+       Tag("color_tex"),
+       Tag()
+};
+
+UnlitMaterial::UnlitMaterial()
+{
+       set_color(Color(1.0f));
 }
 
-string UnlitMaterial::create_program_source() const
+void UnlitMaterial::fill_program_info(string &module_name, map<string, int> &spec_values) const
 {
-       string source = "import unlit;\n";
-       if(texture)
-               source += "const bool use_texture = true;\n";
-       if(vertex_color)
-               source += "const bool use_vertex_color = true;\n";
-       return source;
+       module_name = "unlit.glsl";
+       spec_values["use_texture"] = (texture!=0);
+       spec_values["use_vertex_color"] = vertex_color;
 }
 
-void UnlitMaterial::attach_textures_to(Texturing &texturing, ProgramData &tex_shdata) const
+const Texture *UnlitMaterial::get_texture(Tag tag) const
 {
-       attach_texture_to(texture, texturing, tex_shdata, "texture");
+       if(tag==texture_tags[0])
+               return texture;
+       else
+               return 0;
 }
 
 void UnlitMaterial::set_texture(const Texture *tex)
@@ -32,10 +36,10 @@ void UnlitMaterial::set_texture(const Texture *tex)
        texture = tex;
 }
 
-void UnlitMaterial::set_tint(const Color &t)
+void UnlitMaterial::set_color(const Color &c)
 {
-       tint = t;
-       shdata.uniform("tint", tint);
+       color = c;
+       shdata.uniform("unlit_material.color", color);
 }
 
 void UnlitMaterial::set_vertex_color(bool vc)
@@ -46,12 +50,6 @@ void UnlitMaterial::set_vertex_color(bool vc)
 
 DataFile::Loader::ActionMap UnlitMaterial::Loader::shared_actions;
 
-UnlitMaterial::Loader::Loader(UnlitMaterial &m):
-       DerivedObjectLoader<UnlitMaterial, Material::PropertyLoader<UnlitMaterial> >(m)
-{
-       set_actions(shared_actions);
-}
-
 UnlitMaterial::Loader::Loader(UnlitMaterial &m, Collection &c):
        DerivedObjectLoader<UnlitMaterial, Material::PropertyLoader<UnlitMaterial> >(m, c)
 {
@@ -62,7 +60,7 @@ void UnlitMaterial::Loader::init_actions()
 {
        Material::PropertyLoader<UnlitMaterial>::init_actions();
        add("texture", &Loader::property_texture, &UnlitMaterial::set_texture);
-       add_property("tint", &UnlitMaterial::set_tint, 0, true);
+       add_property("color", &UnlitMaterial::set_color, 0, true);
        add("vertex_color", &UnlitMaterial::vertex_color);
 }