]> git.tdb.fi Git - libs/gl.git/blobdiff - source/materials/renderpass.cpp
Remove deprecated interfaces from material and lighting code
[libs/gl.git] / source / materials / renderpass.cpp
index 43d5803e7f1d0a799880ff99a9d8af7375cec1df..a055f4786bfed69a39c871087d31b47a123c6f1c 100644 (file)
@@ -1,6 +1,5 @@
 #include <msp/core/algorithm.h>
 #include <msp/datafile/collection.h>
-#include <msp/io/print.h>
 #include <msp/strings/format.h>
 #include "error.h"
 #include "renderpass.h"
@@ -9,7 +8,6 @@
 #include "renderer.h"
 #include "texture.h"
 #include "texture2d.h"
-#include "uniform.h"
 
 using namespace std;
 
@@ -93,36 +91,6 @@ Tag RenderPass::get_texture_tag(const string &slot) const
        return (i!=textures.end() ? i->tag : Tag());
 }
 
-void RenderPass::set_texture(unsigned index, const Texture *tex, const Sampler *samp)
-{
-       if(!shprog)
-               throw invalid_operation("RenderPass::set_texture");
-
-       const vector<ReflectData::UniformInfo> &uniforms = shprog->get_uniforms();
-       for(const ReflectData::UniformInfo &u: uniforms)
-               if(is_image(u.type) && u.binding==static_cast<int>(index))
-                       return set_texture(u.tag, tex, samp);
-
-       if(shdata)
-       {
-               for(Tag t: shdata->get_uniform_tags())
-               {
-                       auto j = find_member(uniforms, t, &ReflectData::UniformInfo::tag);
-                       if(j==uniforms.end() || !is_image(j->type))
-                               continue;
-                       if(const Uniform1i *uni1i = dynamic_cast<const Uniform1i *>(shdata->find_uniform(t)))
-                               if(uni1i->get()==static_cast<int>(index))
-                                       return set_texture(t, tex, samp);
-               }
-       }
-}
-
-int RenderPass::get_texture_index(const string &n) const
-{
-       auto i = find_member(textures, n, &TextureSlot::slot_name);
-       return (shprog && i!=textures.end() ? shprog->get_uniform_binding(i->tag) : -1);
-}
-
 void RenderPass::set_face_cull(CullMode fc)
 {
        face_cull = fc;
@@ -181,11 +149,6 @@ void RenderPass::Loader::init_actions()
        add("uniforms", &Loader::uniforms);
        add("uniform_slot", &Loader::uniform_slot);
        add("uniform_slot", &Loader::uniform_slot2);
-
-       // Deprecated
-       add("texunit",  &Loader::texunit);
-       add("texunit",  &Loader::texture);
-       add("texunit",  &Loader::texunit_named);
 }
 
 void RenderPass::Loader::set_inline_base_name(const string &n)
@@ -199,17 +162,6 @@ void RenderPass::Loader::finish()
                obj.maybe_create_material_shader();
 }
 
-// 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);
@@ -228,7 +180,7 @@ void RenderPass::Loader::material(const string &name)
 
 void RenderPass::Loader::shader(const string &n)
 {
-       obj.shprog = &get_collection().get<Program>(get_shader_name(n));
+       obj.shprog = &get_collection().get<Program>(n);
        obj.shprog_from_material = false;
        if(obj.shdata)
                obj.shdata = new ProgramData(*obj.shdata, obj.shprog);
@@ -246,35 +198,6 @@ void RenderPass::Loader::texture(const string &n)
        load_sub_with(ldr);
 }
 
-void RenderPass::Loader::texunit(unsigned)
-{
-       IO::print(IO::cerr, "Warning: specifying textures by unit number is deprecated and may not produce expected results");
-       string name;
-       if(obj.shprog)
-       {
-               for(const ReflectData::UniformInfo &u: obj.shprog->get_uniforms())
-                       if(is_image(u.type) && u.binding>=0)
-                       {
-                               if(!name.empty())
-                               {
-                                       name.clear();
-                                       break;
-                               }
-                               name = u.name;
-                       }
-       }
-
-       if(name.empty())
-               throw runtime_error("Could not determine name for texture");
-
-       texture(name);
-}
-
-void RenderPass::Loader::texunit_named(unsigned, const string &n)
-{
-       texture(n);
-}
-
 void RenderPass::Loader::uniforms()
 {
        if(!obj.shprog || obj.shprog_from_material)