X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Frender%2Finstancearray.cpp;h=a03fbf20dff9ca2766c15067087389e0d2902fd3;hb=cc270481e3e2f74d060ce2c63551970c835b06b8;hp=d27fa8196657f1b127f10f4e10e6ccacbf25a1c5;hpb=5bb193f930fb8738d099d630c4d625d82c1215b5;p=libs%2Fgl.git diff --git a/source/render/instancearray.cpp b/source/render/instancearray.cpp index d27fa819..a03fbf20 100644 --- a/source/render/instancearray.cpp +++ b/source/render/instancearray.cpp @@ -15,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) @@ -88,7 +85,7 @@ void InstanceArray::update_instance_matrix(unsigned index) { const Matrix &m = *instances[index]->get_matrix(); - float *d = reinterpret_cast(instance_data.modify(instances.size()-1)+matrix_offset); + float *d = reinterpret_cast(instance_data.modify(index)+matrix_offset); for(unsigned i=0; i<12; ++i) d[i] = m(i/4, i%4); } @@ -101,18 +98,17 @@ 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_data.refresh(); + instance_buffer->storage(instance_data.get_required_buffer_size(), STREAMING); Renderer::Push push(renderer); - pass->apply(renderer); + renderer.set_pipeline_key(this, tag.id); + method->apply(renderer); mesh->draw_instanced(renderer, vtx_setup, instances.size()); }