]> git.tdb.fi Git - libs/gl.git/commitdiff
Rename RenderPass to RenderMethod
authorMikko Rasa <tdb@tdb.fi>
Sat, 2 Oct 2021 16:23:36 +0000 (19:23 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sat, 2 Oct 2021 23:53:13 +0000 (02:53 +0300)
This is mostly to avoid confusion with Vulkan's render passes, which are
an entirely different thing.

14 files changed:
blender/io_mspgl/export_material.py
blender/io_mspgl/export_object.py
source/materials/rendermethod.cpp [new file with mode: 0644]
source/materials/rendermethod.h [new file with mode: 0644]
source/materials/renderpass.cpp [deleted file]
source/materials/renderpass.h [deleted file]
source/materials/technique.cpp
source/materials/technique.h
source/render/instancearray.cpp
source/render/object.cpp
source/render/object.h
source/render/renderable.h
source/render/text.cpp
tools/viewer.cpp

index 8a87011a25d93d1c54bb376c05ba02473488ab3e..e7c1a50d49838523e3ae991d4c3c62952a7d4393 100644 (file)
@@ -7,7 +7,7 @@ def create_technique_resource(material, resources):
 
        mat_res = resources[material.name+".mat"]
 
-       st = Statement("pass", "")
+       st = Statement("method", "")
        if mat_res:
                st.sub.append(tech_res.create_embed_statement("material", mat_res))
 
@@ -31,7 +31,7 @@ def create_technique_resource(material, resources):
        tech_res.statements.append(st)
 
        if material.shadow_method!='NONE':
-               st = Statement("pass", "shadow")
+               st = Statement("method", "shadow")
                if material.render_mode=='CUSTOM':
                        shader = material.shadow_shader or material.shader
                        if shader.endswith(".glsl"):
index 177641c83ddf21eecfe7bfd6d9dd4f2659d800b1..32894f7ebc1041d5555ca244d7d93a817381d2b5 100644 (file)
@@ -150,7 +150,7 @@ class ObjectExporter:
        def export_stub_technique(self):
                from .datafile import Resource, Statement
                tech_res = Resource("stub.tech", "technique")
-               pass_st = Statement("pass", "")
+               pass_st = Statement("method", "")
                tech_res.statements.append(pass_st)
                mat_st = Statement("material")
                pass_st.sub.append(mat_st)
diff --git a/source/materials/rendermethod.cpp b/source/materials/rendermethod.cpp
new file mode 100644 (file)
index 0000000..a6a843e
--- /dev/null
@@ -0,0 +1,239 @@
+#include <msp/core/algorithm.h>
+#include <msp/datafile/collection.h>
+#include <msp/strings/format.h>
+#include "error.h"
+#include "rendermethod.h"
+#include "program.h"
+#include "programdata.h"
+#include "renderer.h"
+#include "texture.h"
+#include "texture2d.h"
+
+using namespace std;
+
+namespace Msp {
+namespace GL {
+
+RenderMethod::RenderMethod():
+       shprog(0),
+       shprog_from_material(false),
+       shdata(0),
+       material(0),
+       face_cull(CULL_BACK),
+       receive_shadows(false),
+       image_based_lighting(false)
+{ }
+
+void RenderMethod::set_material_textures()
+{
+       const Tag *material_texture_tags = material->get_texture_tags();
+       for(const Tag *tag=material_texture_tags; tag->id; ++tag)
+               set_texture(*tag, material->get_texture(*tag), material->get_sampler(*tag));
+}
+
+void RenderMethod::maybe_create_material_shader()
+{
+       if(shprog && !shprog_from_material)
+               return;
+
+       map<string, int> extra_spec;
+       if(receive_shadows)
+               extra_spec["use_shadow_map"] = true;
+       if(image_based_lighting)
+               extra_spec["use_image_based_lighting"] = true;
+
+       shprog = material->create_compatible_shader(extra_spec);
+
+       if(shdata)
+               shdata = new ProgramData(*shdata, shprog);
+
+       shprog_from_material = true;
+}
+
+void RenderMethod::set_shader_program(const Program *prog, const ProgramData *data)
+{
+       shprog = prog;
+       shprog_from_material = false;
+       shdata = (data ? new ProgramData(*data) : 0);
+}
+
+Tag RenderMethod::get_slotted_uniform_tag(Tag slot) const
+{
+       auto i = uniform_slots.find(slot);
+       if(i==uniform_slots.end())
+               return Tag();
+       return i->second;
+}
+
+void RenderMethod::set_material(const Material *mat)
+{
+       material = mat;
+       maybe_create_material_shader();
+       set_material_textures();
+}
+
+void RenderMethod::set_texture(Tag tag, const Texture *tex, const Sampler *samp)
+{
+       auto i = find_member(textures, tag, &TextureSlot::tag);
+       if(i==textures.end())
+       {
+               textures.push_back(TextureSlot(tag));
+               i = textures.end()-1;
+       }
+       i->texture = tex;
+       if(samp)
+               i->sampler = samp;
+}
+
+Tag RenderMethod::get_texture_tag(const string &slot) const
+{
+       auto i = find_member(textures, slot, &TextureSlot::slot_name);
+       return (i!=textures.end() ? i->tag : Tag());
+}
+
+void RenderMethod::set_face_cull(CullMode fc)
+{
+       face_cull = fc;
+}
+
+void RenderMethod::set_receive_shadows(bool rs)
+{
+       receive_shadows = rs;
+}
+
+void RenderMethod::apply(Renderer &renderer) const
+{
+       for(const TextureSlot &t: textures)
+               renderer.set_texture(t.tag, t.texture, t.sampler);
+       renderer.set_shader_program(shprog, shdata.get());
+       if(material)
+               renderer.add_shader_data(material->get_shader_data());
+       renderer.set_face_cull(face_cull);
+}
+
+void RenderMethod::set_debug_name(const string &name)
+{
+#ifdef DEBUG
+       if(shdata.refcount()==1)
+               shdata->set_debug_name(name+" [UBO]");
+#else
+       (void)name;
+#endif
+}
+
+
+DataFile::Loader::ActionMap RenderMethod::Loader::shared_actions;
+
+RenderMethod::Loader::Loader(RenderMethod &p):
+       DataFile::CollectionObjectLoader<RenderMethod>(p, 0)
+{
+       set_actions(shared_actions);
+}
+
+RenderMethod::Loader::Loader(RenderMethod &p, Collection &c):
+       DataFile::CollectionObjectLoader<RenderMethod>(p, &c)
+{
+       set_actions(shared_actions);
+}
+
+void RenderMethod::Loader::init_actions()
+{
+       add("face_cull", &RenderMethod::face_cull);
+       add("shader",   &Loader::shader);
+       add("image_based_lighting", &RenderMethod::image_based_lighting);
+       add("material", &Loader::material_inline);
+       add("material", &Loader::material);
+       add("material_slot", &RenderMethod::material_slot);
+       add("receive_shadows", &RenderMethod::receive_shadows);
+       add("texture", &Loader::texture);
+       add("uniforms", &Loader::uniforms);
+       add("uniform_slot", &Loader::uniform_slot);
+       add("uniform_slot", &Loader::uniform_slot2);
+}
+
+void RenderMethod::Loader::set_inline_base_name(const string &n)
+{
+       inline_base_name = n;
+}
+
+void RenderMethod::Loader::finish()
+{
+       if(obj.material)
+               obj.maybe_create_material_shader();
+}
+
+void RenderMethod::Loader::material_inline()
+{
+       Material::GenericLoader ldr(coll);
+       load_sub_with(ldr);
+       RefPtr<Material> mat = ldr.get_material();
+       get_collection().add(inline_base_name+".mat", mat.get());
+       obj.material = mat.release();
+       obj.set_material_textures();
+}
+
+void RenderMethod::Loader::material(const string &name)
+{
+       obj.material = &get_collection().get<Material>(name);
+       obj.set_material_textures();
+}
+
+void RenderMethod::Loader::shader(const string &n)
+{
+       obj.shprog = &get_collection().get<Program>(n);
+       obj.shprog_from_material = false;
+       if(obj.shdata)
+               obj.shdata = new ProgramData(*obj.shdata, obj.shprog);
+}
+
+void RenderMethod::Loader::texture(const string &n)
+{
+       auto i = find_member(obj.textures, Tag(n), &TextureSlot::tag);
+       if(i==obj.textures.end())
+       {
+               obj.textures.push_back(TextureSlot(n));
+               i = obj.textures.end()-1;
+       }
+       TextureSlot::Loader ldr(*i, n, coll);
+       load_sub_with(ldr);
+}
+
+void RenderMethod::Loader::uniforms()
+{
+       if(!obj.shprog || obj.shprog_from_material)
+               throw runtime_error("Shader is required for uniforms");
+       if(!obj.shdata)
+               obj.shdata = new ProgramData(obj.shprog);
+       else if(obj.shdata.refcount()>1)
+               obj.shdata = new ProgramData(*obj.shdata);
+       load_sub(*obj.shdata);
+}
+
+void RenderMethod::Loader::uniform_slot(const string &name)
+{
+       uniform_slot2(name, name);
+}
+
+void RenderMethod::Loader::uniform_slot2(const string &name, const string &slot)
+{
+       obj.uniform_slots[slot] = name;
+}
+
+
+RenderMethod::TextureSlot::Loader::Loader(TextureSlot &ts, const string &an, Collection *c):
+       CollectionObjectLoader<TextureSlot>(ts, c),
+       auto_slot_name(an)
+{
+       add("sampler", &TextureSlot::sampler);
+       add("slot", &Loader::slot_auto);
+       add("slot", &TextureSlot::slot_name);
+       add("texture", &TextureSlot::texture);
+}
+
+void RenderMethod::TextureSlot::Loader::slot_auto()
+{
+       obj.slot_name = auto_slot_name;
+}
+
+} // namespace GL
+} // namespace Msp
diff --git a/source/materials/rendermethod.h b/source/materials/rendermethod.h
new file mode 100644 (file)
index 0000000..11c7e85
--- /dev/null
@@ -0,0 +1,119 @@
+#ifndef MSP_GL_RENDERPASS_H_
+#define MSP_GL_RENDERPASS_H_
+
+#include <msp/core/refptr.h>
+#include <msp/datafile/objectloader.h>
+#include "cullface.h"
+#include "material.h"
+
+namespace Msp {
+namespace GL {
+
+class Program;
+class ProgramData;
+class Renderer;
+class Sampler;
+class Texture;
+
+/**
+Encapsulates the data that determines the appearance of a rendered surface.
+This includes shader and data for it, material and texturing.
+*/
+class RenderMethod
+{
+public:
+       class Loader: public DataFile::CollectionObjectLoader<RenderMethod>
+       {
+       private:
+               std::string inline_base_name;
+
+               static ActionMap shared_actions;
+
+       public:
+               Loader(RenderMethod &);
+               Loader(RenderMethod &, Collection &);
+       private:
+               virtual void init_actions();
+       
+       public:
+               void set_inline_base_name(const std::string &);
+
+       private:
+               virtual void finish();
+
+               void material_inline();
+               void material(const std::string &);
+               void shader(const std::string &);
+               void texture(const std::string &);
+               void uniforms();
+               void uniform_slot(const std::string &);
+               void uniform_slot2(const std::string &, const std::string &);
+       };
+
+private:
+       struct TextureSlot
+       {
+               class Loader: public DataFile::CollectionObjectLoader<TextureSlot>
+               {
+               private:
+                       std::string auto_slot_name;
+
+               public:
+                       Loader(TextureSlot &, const std::string &, Collection *);
+
+               private:
+                       void slot_auto();
+               };
+
+               Tag tag;
+               std::string slot_name;
+               const Texture *texture;
+               const Sampler *sampler;
+
+               TextureSlot(Tag t): tag(t), texture(0), sampler(0) { }
+       };
+
+       const Program *shprog;
+       bool shprog_from_material;
+       RefPtr<ProgramData> shdata;
+       std::map<Tag, Tag> uniform_slots;
+       const Material *material;
+       std::string material_slot;
+       std::vector<TextureSlot> textures;
+       CullMode face_cull;
+       bool receive_shadows;
+       bool image_based_lighting;
+
+public:
+       RenderMethod();
+
+private:
+       void maybe_create_material_shader();
+       void set_material_textures();
+
+public:
+       void set_shader_program(const Program *, const ProgramData *);
+       const Program *get_shader_program() const { return shprog; }
+       const ProgramData *get_shader_data() const { return shdata.get(); }
+       Tag get_slotted_uniform_tag(Tag) const;
+       void set_material(const Material *);
+       const Material *get_material() const { return material; }
+       const std::string &get_material_slot_name() const { return material_slot; }
+       void set_texture(Tag, const Texture *, const Sampler * = 0);
+       Tag get_texture_tag(const std::string &) const;
+       void set_face_cull(CullMode);
+       CullMode get_face_cull() const { return face_cull; }
+       void set_receive_shadows(bool);
+       bool get_receive_shadows() const { return receive_shadows; }
+       void set_image_based_lighting(bool);
+       bool get_image_based_lighting() const { return image_based_lighting; }
+
+       void apply(Renderer &) const;
+
+       void set_debug_name(const std::string &);
+};
+
+} // namespace GL
+} // namespace Msp
+
+#endif
diff --git a/source/materials/renderpass.cpp b/source/materials/renderpass.cpp
deleted file mode 100644 (file)
index a055f47..0000000
+++ /dev/null
@@ -1,239 +0,0 @@
-#include <msp/core/algorithm.h>
-#include <msp/datafile/collection.h>
-#include <msp/strings/format.h>
-#include "error.h"
-#include "renderpass.h"
-#include "program.h"
-#include "programdata.h"
-#include "renderer.h"
-#include "texture.h"
-#include "texture2d.h"
-
-using namespace std;
-
-namespace Msp {
-namespace GL {
-
-RenderPass::RenderPass():
-       shprog(0),
-       shprog_from_material(false),
-       shdata(0),
-       material(0),
-       face_cull(CULL_BACK),
-       receive_shadows(false),
-       image_based_lighting(false)
-{ }
-
-void RenderPass::set_material_textures()
-{
-       const Tag *material_texture_tags = material->get_texture_tags();
-       for(const Tag *tag=material_texture_tags; tag->id; ++tag)
-               set_texture(*tag, material->get_texture(*tag), material->get_sampler(*tag));
-}
-
-void RenderPass::maybe_create_material_shader()
-{
-       if(shprog && !shprog_from_material)
-               return;
-
-       map<string, int> extra_spec;
-       if(receive_shadows)
-               extra_spec["use_shadow_map"] = true;
-       if(image_based_lighting)
-               extra_spec["use_image_based_lighting"] = true;
-
-       shprog = material->create_compatible_shader(extra_spec);
-
-       if(shdata)
-               shdata = new ProgramData(*shdata, shprog);
-
-       shprog_from_material = true;
-}
-
-void RenderPass::set_shader_program(const Program *prog, const ProgramData *data)
-{
-       shprog = prog;
-       shprog_from_material = false;
-       shdata = (data ? new ProgramData(*data) : 0);
-}
-
-Tag RenderPass::get_slotted_uniform_tag(Tag slot) const
-{
-       auto i = uniform_slots.find(slot);
-       if(i==uniform_slots.end())
-               return Tag();
-       return i->second;
-}
-
-void RenderPass::set_material(const Material *mat)
-{
-       material = mat;
-       maybe_create_material_shader();
-       set_material_textures();
-}
-
-void RenderPass::set_texture(Tag tag, const Texture *tex, const Sampler *samp)
-{
-       auto i = find_member(textures, tag, &TextureSlot::tag);
-       if(i==textures.end())
-       {
-               textures.push_back(TextureSlot(tag));
-               i = textures.end()-1;
-       }
-       i->texture = tex;
-       if(samp)
-               i->sampler = samp;
-}
-
-Tag RenderPass::get_texture_tag(const string &slot) const
-{
-       auto i = find_member(textures, slot, &TextureSlot::slot_name);
-       return (i!=textures.end() ? i->tag : Tag());
-}
-
-void RenderPass::set_face_cull(CullMode fc)
-{
-       face_cull = fc;
-}
-
-void RenderPass::set_receive_shadows(bool rs)
-{
-       receive_shadows = rs;
-}
-
-void RenderPass::apply(Renderer &renderer) const
-{
-       for(const TextureSlot &t: textures)
-               renderer.set_texture(t.tag, t.texture, t.sampler);
-       renderer.set_shader_program(shprog, shdata.get());
-       if(material)
-               renderer.add_shader_data(material->get_shader_data());
-       renderer.set_face_cull(face_cull);
-}
-
-void RenderPass::set_debug_name(const string &name)
-{
-#ifdef DEBUG
-       if(shdata.refcount()==1)
-               shdata->set_debug_name(name+" [UBO]");
-#else
-       (void)name;
-#endif
-}
-
-
-DataFile::Loader::ActionMap RenderPass::Loader::shared_actions;
-
-RenderPass::Loader::Loader(RenderPass &p):
-       DataFile::CollectionObjectLoader<RenderPass>(p, 0)
-{
-       set_actions(shared_actions);
-}
-
-RenderPass::Loader::Loader(RenderPass &p, Collection &c):
-       DataFile::CollectionObjectLoader<RenderPass>(p, &c)
-{
-       set_actions(shared_actions);
-}
-
-void RenderPass::Loader::init_actions()
-{
-       add("face_cull", &RenderPass::face_cull);
-       add("shader",   &Loader::shader);
-       add("image_based_lighting", &RenderPass::image_based_lighting);
-       add("material", &Loader::material_inline);
-       add("material", &Loader::material);
-       add("material_slot", &RenderPass::material_slot);
-       add("receive_shadows", &RenderPass::receive_shadows);
-       add("texture", &Loader::texture);
-       add("uniforms", &Loader::uniforms);
-       add("uniform_slot", &Loader::uniform_slot);
-       add("uniform_slot", &Loader::uniform_slot2);
-}
-
-void RenderPass::Loader::set_inline_base_name(const string &n)
-{
-       inline_base_name = n;
-}
-
-void RenderPass::Loader::finish()
-{
-       if(obj.material)
-               obj.maybe_create_material_shader();
-}
-
-void RenderPass::Loader::material_inline()
-{
-       Material::GenericLoader ldr(coll);
-       load_sub_with(ldr);
-       RefPtr<Material> mat = ldr.get_material();
-       get_collection().add(inline_base_name+".mat", mat.get());
-       obj.material = mat.release();
-       obj.set_material_textures();
-}
-
-void RenderPass::Loader::material(const string &name)
-{
-       obj.material = &get_collection().get<Material>(name);
-       obj.set_material_textures();
-}
-
-void RenderPass::Loader::shader(const string &n)
-{
-       obj.shprog = &get_collection().get<Program>(n);
-       obj.shprog_from_material = false;
-       if(obj.shdata)
-               obj.shdata = new ProgramData(*obj.shdata, obj.shprog);
-}
-
-void RenderPass::Loader::texture(const string &n)
-{
-       auto i = find_member(obj.textures, Tag(n), &TextureSlot::tag);
-       if(i==obj.textures.end())
-       {
-               obj.textures.push_back(TextureSlot(n));
-               i = obj.textures.end()-1;
-       }
-       TextureSlot::Loader ldr(*i, n, coll);
-       load_sub_with(ldr);
-}
-
-void RenderPass::Loader::uniforms()
-{
-       if(!obj.shprog || obj.shprog_from_material)
-               throw runtime_error("Shader is required for uniforms");
-       if(!obj.shdata)
-               obj.shdata = new ProgramData(obj.shprog);
-       else if(obj.shdata.refcount()>1)
-               obj.shdata = new ProgramData(*obj.shdata);
-       load_sub(*obj.shdata);
-}
-
-void RenderPass::Loader::uniform_slot(const string &name)
-{
-       uniform_slot2(name, name);
-}
-
-void RenderPass::Loader::uniform_slot2(const string &name, const string &slot)
-{
-       obj.uniform_slots[slot] = name;
-}
-
-
-RenderPass::TextureSlot::Loader::Loader(TextureSlot &ts, const string &an, Collection *c):
-       CollectionObjectLoader<TextureSlot>(ts, c),
-       auto_slot_name(an)
-{
-       add("sampler", &TextureSlot::sampler);
-       add("slot", &Loader::slot_auto);
-       add("slot", &TextureSlot::slot_name);
-       add("texture", &TextureSlot::texture);
-}
-
-void RenderPass::TextureSlot::Loader::slot_auto()
-{
-       obj.slot_name = auto_slot_name;
-}
-
-} // namespace GL
-} // namespace Msp
diff --git a/source/materials/renderpass.h b/source/materials/renderpass.h
deleted file mode 100644 (file)
index ae9e34b..0000000
+++ /dev/null
@@ -1,119 +0,0 @@
-#ifndef MSP_GL_RENDERPASS_H_
-#define MSP_GL_RENDERPASS_H_
-
-#include <msp/core/refptr.h>
-#include <msp/datafile/objectloader.h>
-#include "cullface.h"
-#include "material.h"
-
-namespace Msp {
-namespace GL {
-
-class Program;
-class ProgramData;
-class Renderer;
-class Sampler;
-class Texture;
-
-/**
-Encapsulates the data that determines the appearance of a rendered surface.
-This includes shader and data for it, material and texturing.
-*/
-class RenderPass
-{
-public:
-       class Loader: public DataFile::CollectionObjectLoader<RenderPass>
-       {
-       private:
-               std::string inline_base_name;
-
-               static ActionMap shared_actions;
-
-       public:
-               Loader(RenderPass &);
-               Loader(RenderPass &, Collection &);
-       private:
-               virtual void init_actions();
-       
-       public:
-               void set_inline_base_name(const std::string &);
-
-       private:
-               virtual void finish();
-
-               void material_inline();
-               void material(const std::string &);
-               void shader(const std::string &);
-               void texture(const std::string &);
-               void uniforms();
-               void uniform_slot(const std::string &);
-               void uniform_slot2(const std::string &, const std::string &);
-       };
-
-private:
-       struct TextureSlot
-       {
-               class Loader: public DataFile::CollectionObjectLoader<TextureSlot>
-               {
-               private:
-                       std::string auto_slot_name;
-
-               public:
-                       Loader(TextureSlot &, const std::string &, Collection *);
-
-               private:
-                       void slot_auto();
-               };
-
-               Tag tag;
-               std::string slot_name;
-               const Texture *texture;
-               const Sampler *sampler;
-
-               TextureSlot(Tag t): tag(t), texture(0), sampler(0) { }
-       };
-
-       const Program *shprog;
-       bool shprog_from_material;
-       RefPtr<ProgramData> shdata;
-       std::map<Tag, Tag> uniform_slots;
-       const Material *material;
-       std::string material_slot;
-       std::vector<TextureSlot> textures;
-       CullMode face_cull;
-       bool receive_shadows;
-       bool image_based_lighting;
-
-public:
-       RenderPass();
-
-private:
-       void maybe_create_material_shader();
-       void set_material_textures();
-
-public:
-       void set_shader_program(const Program *, const ProgramData *);
-       const Program *get_shader_program() const { return shprog; }
-       const ProgramData *get_shader_data() const { return shdata.get(); }
-       Tag get_slotted_uniform_tag(Tag) const;
-       void set_material(const Material *);
-       const Material *get_material() const { return material; }
-       const std::string &get_material_slot_name() const { return material_slot; }
-       void set_texture(Tag, const Texture *, const Sampler * = 0);
-       Tag get_texture_tag(const std::string &) const;
-       void set_face_cull(CullMode);
-       CullMode get_face_cull() const { return face_cull; }
-       void set_receive_shadows(bool);
-       bool get_receive_shadows() const { return receive_shadows; }
-       void set_image_based_lighting(bool);
-       bool get_image_based_lighting() const { return image_based_lighting; }
-
-       void apply(Renderer &) const;
-
-       void set_debug_name(const std::string &);
-};
-
-} // namespace GL
-} // namespace Msp
-
-#endif
index 122eaf73d412f8f91f5c6fbf3690d6240cfea057..268149f8cb4bff921d9459d2e721e99235fd6257 100644 (file)
@@ -12,31 +12,31 @@ using namespace std;
 namespace Msp {
 namespace GL {
 
-RenderPass &Technique::add_pass(Tag tag)
+RenderMethod &Technique::add_method(Tag tag)
 {
-       return insert_unique(passes, tag, RenderPass())->second;
+       return insert_unique(methods, tag, RenderMethod())->second;
 }
 
-bool Technique::has_pass(Tag tag) const
+bool Technique::has_method(Tag tag) const
 {
-       return passes.count(tag);
+       return methods.count(tag);
 }
 
-const RenderPass &Technique::get_pass(Tag tag) const
+const RenderMethod &Technique::get_method(Tag tag) const
 {
-       return get_item(passes, tag);
+       return get_item(methods, tag);
 }
 
-const RenderPass *Technique::find_pass(Tag tag) const
+const RenderMethod *Technique::find_method(Tag tag) const
 {
-       auto i = passes.find(tag);
-       return (i!=passes.end() ? &i->second : 0);
+       auto i = methods.find(tag);
+       return (i!=methods.end() ? &i->second : 0);
 }
 
 bool Technique::replace_texture(const string &slot, const Texture &tex)
 {
        bool replaced = false;
-       for(auto &kvp: passes)
+       for(auto &kvp: methods)
        {
                Tag tag = kvp.second.get_texture_tag(slot);
                if(tag.id)
@@ -52,7 +52,7 @@ bool Technique::replace_texture(const string &slot, const Texture &tex)
 bool Technique::replace_material(const string &slot, const Material &mat)
 {
        bool replaced = false;
-       for(auto &kvp: passes)
+       for(auto &kvp: methods)
        {
                const string &pass_slot = kvp.second.get_material_slot_name();
                if(!pass_slot.empty() && pass_slot==slot)
@@ -69,7 +69,7 @@ bool Technique::replace_uniforms(const ProgramData &shdata)
 {
        bool replaced = false;
        const vector<Tag> &uniform_tags = shdata.get_uniform_tags();
-       for(auto &kvp: passes)
+       for(auto &kvp: methods)
        {
                RefPtr<ProgramData> new_shdata;
                for(Tag t: uniform_tags)
@@ -95,8 +95,8 @@ bool Technique::replace_uniforms(const ProgramData &shdata)
 void Technique::set_debug_name(const string &name)
 {
 #ifdef DEBUG
-       for(auto &kvp: passes)
-               kvp.second.set_debug_name(format("%s [pass:%s]", name, kvp.first.str()));
+       for(auto &kvp: methods)
+               kvp.second.set_debug_name(format("%s [method:%s]", name, kvp.first.str()));
 #else
        (void)name;
 #endif
@@ -120,7 +120,7 @@ Technique::Loader::Loader(Technique &t, Collection &c):
 void Technique::Loader::init_actions()
 {
        add("inherit", &Loader::inherit);
-       add("pass", &Loader::pass);
+       add("method", &Loader::method);
 }
 
 void Technique::Loader::set_inline_base_name(const string &n)
@@ -130,27 +130,27 @@ void Technique::Loader::set_inline_base_name(const string &n)
 
 void Technique::Loader::inherit(const string &n)
 {
-       obj.passes = get_collection().get<Technique>(n).get_passes();
+       obj.methods = get_collection().get<Technique>(n).get_methods();
        InheritLoader ldr(obj, get_collection());
        load_sub_with(ldr);
 }
 
-void Technique::Loader::pass(const string &n)
+void Technique::Loader::method(const string &n)
 {
-       RenderPass p;
+       RenderMethod p;
        if(coll)
        {
-               RenderPass::Loader ldr(p, get_collection());
-               ldr.set_inline_base_name(format("%s/%s.pass", (inline_base_name.empty() ? FS::basename(get_source()) : inline_base_name), n));
+               RenderMethod::Loader ldr(p, get_collection());
+               ldr.set_inline_base_name(format("%s/%s.method", (inline_base_name.empty() ? FS::basename(get_source()) : inline_base_name), n));
                load_sub_with(ldr);
        }
        else
                load_sub(p);
 
        if(!p.get_shader_program())
-               throw logic_error("no shader program in pass");
+               throw logic_error("no shader program in method");
 
-       insert_unique(obj.passes, n, p);
+       insert_unique(obj.methods, n, p);
 }
 
 
@@ -169,15 +169,15 @@ void Technique::InheritLoader::material(const string &slot, const string &name)
                return;
 
        // For backwards compatibility
-       RenderPass &pass = get_item(obj.passes, slot);
-       if(const Material *base_mat = pass.get_material())
+       RenderMethod &method = get_item(obj.methods, slot);
+       if(const Material *base_mat = method.get_material())
        {
-               for(auto &kvp: obj.passes)
+               for(auto &kvp: obj.methods)
                        if(kvp.second.get_material()==base_mat)
                                kvp.second.set_material(&mat);
        }
        else
-               pass.set_material(&mat);
+               method.set_material(&mat);
 }
 
 void Technique::InheritLoader::texture(const string &slot, const string &name)
index c2b69bf7bc48625b4eae4e5526aab001731c19cb..4e6b908d7847c470a4fc06ec2d5225f57a54aed2 100644 (file)
@@ -2,7 +2,7 @@
 #define MSP_GL_TECHNIQUE_H_
 
 #include <map>
-#include "renderpass.h"
+#include "rendermethod.h"
 #include "tag.h"
 
 namespace Msp {
@@ -12,7 +12,7 @@ class Material;
 class Texture;
 
 /**
-Ties multiple tagged render passes together.
+Ties multiple tagged render methods together.
 */
 class Technique
 {
@@ -35,7 +35,7 @@ public:
 
        private:
                void inherit(const std::string &);
-               void pass(const std::string &);
+               void method(const std::string &);
        };
 
 private:
@@ -50,14 +50,14 @@ private:
                void uniforms();
        };
 
-       std::map<Tag, RenderPass> passes;
+       std::map<Tag, RenderMethod> methods;
 
 public:
-       RenderPass &add_pass(Tag);
-       bool has_pass(Tag) const;
-       const RenderPass &get_pass(Tag) const;
-       const RenderPass *find_pass(Tag) const;
-       const std::map<Tag, RenderPass> &get_passes() const { return passes; }
+       RenderMethod &add_method(Tag);
+       bool has_method(Tag) const;
+       const RenderMethod &get_method(Tag) const;
+       const RenderMethod *find_method(Tag) const;
+       const std::map<Tag, RenderMethod> &get_methods() const { return methods; }
        bool replace_texture(const std::string &, const Texture &);
        bool replace_material(const std::string &, const Material &);
        bool replace_uniforms(const ProgramData &);
index d27fa8196657f1b127f10f4e10e6ccacbf25a1c5..f6a7bb634bd450c0f6f4d4011655331ca72e93ea 100644 (file)
@@ -21,7 +21,7 @@ InstanceArray::InstanceArray(const Object &o):
        matrix_offset(0)
 {
        const Technique *tech = object.get_technique();
-       for(const auto &kvp: tech->get_passes())
+       for(const auto &kvp: tech->get_methods())
        {
                const Program *shprog = kvp.second.get_shader_program();
                if(!shprog)
@@ -101,8 +101,8 @@ void InstanceArray::render(Renderer &renderer, Tag tag) const
        const Technique *tech = object.get_technique();
        if(!tech)
                throw logic_error("no technique");
-       const RenderPass *pass = tech->find_pass(tag);
-       if(!pass)
+       const RenderMethod *method = tech->find_method(tag);
+       if(!method)
                return;
 
        const Mesh *mesh = object.get_mesh();
@@ -112,7 +112,7 @@ void InstanceArray::render(Renderer &renderer, Tag tag) const
        instance_data.refresh();
 
        Renderer::Push push(renderer);
-       pass->apply(renderer);
+       method->apply(renderer);
        mesh->draw_instanced(renderer, vtx_setup, instances.size());
 }
 
index 34eebec782472880484179df7cf2175303086bab..b63434742b7ef8a7305a2bbcaed7e3e85a9ba98b 100644 (file)
@@ -130,8 +130,8 @@ const Technique *Object::get_technique(unsigned i) const
 
 void Object::render(Renderer &renderer, Tag tag) const
 {
-       const RenderPass *pass = get_pass(tag, 0);
-       if(!pass)
+       const RenderMethod *method = get_method(tag, 0);
+       if(!method)
                return;
 
        const Mesh *mesh = lods.front().mesh;
@@ -139,7 +139,7 @@ void Object::render(Renderer &renderer, Tag tag) const
                throw logic_error("no mesh");
 
        Renderer::Push push(renderer);
-       pass->apply(renderer);
+       method->apply(renderer);
 
        setup_render(renderer, tag);
        mesh->draw(renderer);
@@ -149,8 +149,8 @@ void Object::render(Renderer &renderer, Tag tag) const
 void Object::render(Renderer &renderer, const ObjectInstance &inst, Tag tag) const
 {
        unsigned lod = min<unsigned>(inst.get_level_of_detail(renderer), lods.size()-1);
-       const RenderPass *pass = get_pass(tag, lod);
-       if(!pass)
+       const RenderMethod *method = get_method(tag, lod);
+       if(!method)
                return;
 
        const Mesh *mesh = lods[lod].mesh;
@@ -158,7 +158,7 @@ void Object::render(Renderer &renderer, const ObjectInstance &inst, Tag tag) con
                throw logic_error("no mesh");
 
        Renderer::Push push(renderer);
-       pass->apply(renderer);
+       method->apply(renderer);
 
        setup_render(renderer, tag);
        inst.setup_render(renderer, tag);
@@ -167,12 +167,12 @@ void Object::render(Renderer &renderer, const ObjectInstance &inst, Tag tag) con
        finish_render(renderer, tag);
 }
 
-const RenderPass *Object::get_pass(Tag tag, unsigned lod) const
+const RenderMethod *Object::get_method(Tag tag, unsigned lod) const
 {
        const Technique *tech = lods[lod].technique;
        if(!tech)
                throw logic_error("no technique");
-       return tech->find_pass(tag);
+       return tech->find_method(tag);
 }
 
 void Object::resource_loaded(Resource &res)
index ac62c702b4e1e2f9c6033c40e95e2db812b84735..dea389e4b8ae4d0d841ccbea333341bbc2a40ef9 100644 (file)
@@ -3,7 +3,7 @@
 
 #include <vector>
 #include "renderable.h"
-#include "renderpass.h"
+#include "rendermethod.h"
 #include "resourceobserver.h"
 
 namespace Msp {
@@ -118,7 +118,7 @@ protected:
        virtual void finish_render(Renderer &, Tag) const { }
 
 private:
-       const RenderPass *get_pass(Tag, unsigned) const;
+       const RenderMethod *get_method(Tag, unsigned) const;
 
        virtual void resource_loaded(Resource &);
        virtual void resource_removed(Resource &);
index 022c87087b7b08bcf1f6034d1668b79df2021ee4..aa895eedbd0f0a128f6c1da617ca0e67b4ec2a44 100644 (file)
@@ -14,7 +14,7 @@ class Renderer;
 Base class for renderable objects.  Rendering is performed with the help of a
 Renderer object.
 
-The render method takes a Tag to identify a render pass.  It can be used with
+The render method takes a Tag to identify a render method.  It can be used with
 a Technique to select alternative rendering methods, such as simplified shaders
 for a depth-only shadow pass.
 
index 5305de4bd5b46db5f12874aa9a03ec73e27bcd8c..cb7f998e9bb2a38d4102024fc4648e8461b38f0c 100644 (file)
@@ -27,8 +27,8 @@ void Text::set_technique(const Technique *tech, Tag tex_slot)
 {
        if(tech)
        {
-               if(!tex_slot.id && tech->has_pass(Tag()))
-                       if(const Program *shprog = tech->get_pass(Tag()).get_shader_program())
+               if(!tex_slot.id && tech->has_method(Tag()))
+                       if(const Program *shprog = tech->get_method(Tag()).get_shader_program())
                        {
                                if(shprog->get_uniform_location(Tag("font_tex"))>=0)
                                        tex_slot = "font_tex";
index 4c7b01e8ac71172d4f23e272dc6de276f5dba58c..a1703ede17d5621b98954db1deef56e57132ab86 100644 (file)
@@ -177,7 +177,7 @@ Viewer::Viewer(int argc, char **argv):
 
                object = new GL::Object;
                GL::Technique *tech = new GL::Technique;
-               tech->add_pass(0);
+               tech->add_method(0);
                object->set_mesh(mesh);
                object->set_technique(tech);
                renderable = object;