X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fmaterials%2Frenderpass.cpp;h=810b3673e584671423c95795a0eaab5cdd9c5e93;hb=4c856cc3c0425fef1d123fe846ab19fbb10ab6c6;hp=835e78a672cd6203649cdd9cbba4345421fa41b8;hpb=7aaec9a70b8d7733429bec043f8e33e02956f266;p=libs%2Fgl.git diff --git a/source/materials/renderpass.cpp b/source/materials/renderpass.cpp index 835e78a6..810b3673 100644 --- a/source/materials/renderpass.cpp +++ b/source/materials/renderpass.cpp @@ -1,4 +1,5 @@ #include +#include #include #include "error.h" #include "material.h" @@ -76,7 +77,7 @@ void RenderPass::maybe_create_material_shader(DataFile::Collection *coll) shprog.keep(); } else - shprog = material->create_compatible_shader(); + throw invalid_operation("no collection"); if(shdata) shdata = new ProgramData(*shdata, shprog.get()); @@ -116,19 +117,19 @@ const string &RenderPass::get_slotted_uniform_name(const string &slot) const return i->second; } -void RenderPass::set_material(const Material *mat) +void RenderPass::set_material(const Material *mat, DataFile::Collection *coll) { material = mat; material.keep(); - finalize_material(0); + finalize_material(coll); } -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 @@ -175,6 +176,17 @@ void RenderPass::Loader::init() 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); @@ -192,7 +204,7 @@ void RenderPass::Loader::material(const string &name) void RenderPass::Loader::shader(const string &n) { - obj.shprog = &get_collection().get(n); + obj.shprog = &get_collection().get(get_shader_name(n)); obj.shprog.keep(); obj.shprog_from_material = false; if(obj.shdata)