--- /dev/null
+#include "unlitmaterial.h"
+
+using namespace std;
+
+namespace Msp {
+namespace GL {
+
+UnlitMaterial::UnlitMaterial():
+ texture(0),
+ vertex_color(false)
+{
+ set_tint(Color(1.0f));
+}
+
+string UnlitMaterial::create_program_source() 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;
+}
+
+void UnlitMaterial::attach_textures_to(Texturing &texturing, ProgramData &tex_shdata) const
+{
+ attach_texture_to(texture, texturing, tex_shdata, "texture");
+}
+
+void UnlitMaterial::set_texture(const Texture *tex)
+{
+ texture = tex;
+}
+
+void UnlitMaterial::set_tint(const Color &t)
+{
+ tint = t;
+ shdata.uniform("tint", tint);
+}
+
+void UnlitMaterial::set_vertex_color(bool vc)
+{
+ vertex_color = 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)
+{
+ set_actions(shared_actions);
+}
+
+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("vertex_color", &UnlitMaterial::vertex_color);
+}
+
+} // namespace GL
+} // namespace Msp
--- /dev/null
+#ifndef MSP_GL_UNLITMATERIAL_H_
+#define MSP_GL_UNLITMATERIAL_H_
+
+#include "material.h"
+
+namespace Msp {
+namespace GL {
+
+class UnlitMaterial: public Material
+{
+public:
+ class Loader: public DataFile::DerivedObjectLoader<UnlitMaterial, Material::PropertyLoader<UnlitMaterial> >
+ {
+ private:
+ static ActionMap shared_actions;
+
+ public:
+ Loader(UnlitMaterial &);
+ Loader(UnlitMaterial &, Collection &);
+
+ private:
+ virtual void init_actions();
+
+ void texture(const std::string &);
+ };
+
+private:
+ const Texture *texture;
+ Color tint;
+ bool vertex_color;
+
+public:
+ UnlitMaterial();
+
+protected:
+ virtual std::string create_program_source() const;
+
+public:
+ virtual void attach_textures_to(Texturing &, ProgramData &) const;
+
+ void set_texture(const Texture *);
+ void set_tint(const Color &);
+ void set_vertex_color(bool);
+};
+
+} // namespace GL
+} // namespace Msp
+
+#endif