/* $Id$
This file is part of libmspgl
-Copyright © 2007 Mikko Rasa, Mikkosoft Productions
+Copyright © 2007-2008, 2010-2011 Mikko Rasa, Mikkosoft Productions
Distributed under the LGPL
*/
{ }
RenderPass::RenderPass(const RenderPass &other):
- Bindable<RenderPass>(other),
shprog(other.shprog),
shdata(other.shdata ? new ProgramData(*other.shdata) : 0),
material(other.material),
texturing->attach(index, *tex);
}
-void RenderPass::bind() const
-{
- const RenderPass *old = current();
- if(!set_current(this))
- return;
-
- if(shprog)
- {
- shprog->bind();
- shdata->apply();
- }
- else if(old && old->shprog)
- Program::unbind();
-
- if(material)
- material->bind();
- else if(old && old->material)
- Material::unbind();
-
- if(texturing)
- texturing->bind();
- else if(old && old->texturing)
- Texturing::unbind();
-}
-
-void RenderPass::unbind()
-{
- const RenderPass *old = current();
- if(!set_current(0))
- return;
-
- if(old->shprog)
- Program::unbind();
-
- if(old->material)
- Material::unbind();
-
- if(old->texturing)
- Texturing::unbind();
-}
-
RenderPass::Loader::Loader(RenderPass &p):
DataFile::CollectionObjectLoader<RenderPass>(p, 0)
allow_pointer_reload = false;
add("shader", &RenderPass::shprog);
- add("material", static_cast<void (Loader::*)()>(&Loader::material));
- add("material", static_cast<void (Loader::*)(const string &)>(&Loader::material));
+ add("material", &Loader::material_inline);
+ add("material", &Loader::material);
add("texunit", &Loader::texunit);
add("uniforms", &Loader::uniforms);
}
obj.shdata = new ProgramData;
}
-void RenderPass::Loader::material()
+void RenderPass::Loader::material_inline()
{
RefPtr<Material> mat = new Material;
load_sub(*mat);