#include <msp/datafile/collection.h>
+#include <msp/io/print.h>
#include <msp/strings/format.h>
#include "error.h"
#include "material.h"
shprog.keep();
}
else
- shprog = material->create_compatible_shader();
+ throw invalid_operation("no collection");
if(shdata)
shdata = new ProgramData(*shdata, shprog.get());
finalize_material(0);
}
-void RenderPass::set_texture(unsigned index, const Texture *tex)
+void RenderPass::set_texture(unsigned index, const Texture *tex, const Sampler *samp)
{
if(!texturing)
texturing = new Texturing;
- texturing->attach(index, *tex, texturing->get_attached_sampler(index));
+ texturing->attach(index, *tex, (samp ? samp : texturing->get_attached_sampler(index)));
}
int RenderPass::get_texture_index(const string &n) const
add("uniform_slot", &Loader::uniform_slot2);
}
+// Temporary compatibility feature
+string RenderPass::Loader::get_shader_name(const string &n)
+{
+ if(n.size()>=5 && !n.compare(n.size()-5, 5, ".glsl"))
+ {
+ IO::print(IO::cerr, "Warning: Loading module '%s' as shader is deprecated\n", n);
+ return n+".shader";
+ }
+ return n;
+}
+
void RenderPass::Loader::material_inline()
{
Material::GenericLoader ldr(coll);
void RenderPass::Loader::shader(const string &n)
{
- obj.shprog = &get_collection().get<Program>(n);
+ obj.shprog = &get_collection().get<Program>(get_shader_name(n));
obj.shprog.keep();
obj.shprog_from_material = false;
if(obj.shdata)