]> git.tdb.fi Git - libs/gl.git/blobdiff - source/render/instancearray.cpp
Add a usage parameter to Buffer
[libs/gl.git] / source / render / instancearray.cpp
index 37d7ccb68e3815f8f24b31351d904f4f41175490..eec72f98dc18144c777f8ae61bb5eb3d18677db0 100644 (file)
@@ -1,7 +1,6 @@
 #include <msp/core/algorithm.h>
 #include <msp/core/maputils.h>
 #include "buffer.h"
-#include "camera.h"
 #include "instancearray.h"
 #include "mesh.h"
 #include "object.h"
@@ -16,13 +15,10 @@ namespace Msp {
 namespace GL {
 
 InstanceArray::InstanceArray(const Object &o):
-       object(o),
-       instance_buffer(0),
-       matrix_location(-1),
-       matrix_offset(0)
+       object(o)
 {
        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)
@@ -102,18 +98,18 @@ 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();
        mesh->get_vertices().refresh();
        if(instance_buffer->get_size()==0)
-               instance_buffer->storage(instance_data.get_required_buffer_size());
+               instance_buffer->storage(instance_data.get_required_buffer_size(), STREAMING);
        instance_data.refresh();
 
        Renderer::Push push(renderer);
-       pass->apply(renderer);
+       method->apply(renderer);
        mesh->draw_instanced(renderer, vtx_setup, instances.size());
 }