]> git.tdb.fi Git - libs/gl.git/blobdiff - source/object.cpp
Check the flat qualifier from the correct member
[libs/gl.git] / source / object.cpp
diff --git a/source/object.cpp b/source/object.cpp
deleted file mode 100644 (file)
index 0469c31..0000000
+++ /dev/null
@@ -1,142 +0,0 @@
-/* $Id$
-
-This file is part of libmspgl
-Copyright © 2007  Mikko Rasa, Mikkosoft Productions
-Distributed under the LGPL
-*/
-
-#include "except.h"
-#include "material.h"
-#include "mesh.h"
-#include "object.h"
-#include "objectinstance.h"
-#include "program.h"
-#include "programdata.h"
-#include "texture.h"
-#include "texunit.h"
-
-using namespace std;
-
-namespace Msp {
-namespace GL {
-
-Object::Object():
-       mesh(0),
-       shprog(0),
-       shdata(0),
-       material(0)
-{ }
-
-Object::~Object()
-{
-       delete shdata;
-}
-
-void Object::render(const ObjectInstance *inst) const
-{
-       setup_render();
-
-       if(inst)
-               inst->setup_render();
-
-       mesh->draw();
-
-       if(inst)
-               inst->finish_render();
-
-       finish_render();
-}
-
-void Object::render(const list<const ObjectInstance *> &insts) const
-{
-       setup_render();
-
-       for(list<const ObjectInstance *>::const_iterator i=insts.begin(); i!=insts.end(); ++i)
-       {
-               (*i)->setup_render();
-
-               mesh->draw();
-
-               (*i)->finish_render();
-       }
-
-       finish_render();
-}
-
-void Object::setup_render() const
-{
-       if(!mesh)
-               throw InvalidState("Trying to render Object without mesh");
-
-       if(shprog)
-       {
-               shprog->bind();
-               shdata->apply();
-               for(unsigned i=0; i<textures.size(); ++i)
-               {
-                       TexUnit::activate(i);
-                       textures[i]->bind();
-               }
-       }
-       else if(!textures.empty())
-               textures.front()->bind();
-
-       if(material)
-               material->apply();
-}
-
-void Object::finish_render() const
-{
-       if(shprog)
-               Program::unbind();
-       for(unsigned i=0; i<textures.size(); ++i)
-       {
-               TexUnit::activate(i);
-               Texture::unbind();
-       }
-}
-
-
-Object::Loader::Loader(Object &o, Collection &c):
-       obj(o),
-       coll(c)
-{
-       add("material", &Object::material);
-       add("mesh",     &Object::mesh);
-       add("shader",   &Loader::shader);
-       add("texture",  &Loader::texture);
-}
-
-Object::Loader::~Loader()
-{
-       if(obj.shdata)
-       {
-               for(unsigned i=0; i<textures.size(); ++i)
-                       obj.shdata->uniform(obj.shprog->get_uniform_location(textures[i]), static_cast<int>(i));
-       }
-}
-
-void Object::Loader::shader(const string &n)
-{
-       obj.shprog=&coll.get<Program>(n);
-       if(!obj.shdata)
-               obj.shdata=new ProgramData;
-}
-
-void Object::Loader::texture(const string &n)
-{
-       unsigned eqsign=n.find('=');
-       if(eqsign!=string::npos)
-       {
-               obj.textures.push_back(&coll.get<Texture>(n.substr(eqsign+1)));
-               textures.push_back(n.substr(0, eqsign));
-       }
-       else
-       {
-               obj.textures.push_back(&coll.get<Texture>(n));
-               textures.push_back(n);
-       }
-}
-
-} // namespace GL
-} // namespace Msp