- if(instance_data)
- {
- const Technique *tech = object.get_technique();
- if(!tech)
- throw logic_error("no technique");
- const RenderPass *pass = tech->find_pass(tag);
- if(!pass)
- 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();
-
- Renderer::Push push(renderer);
- pass->apply(renderer);
- mesh->draw_instanced(renderer, *vtx_setup, instances.size());
- }
- else
- {
- for(vector<ObjectInstance *>::const_iterator i=instances.begin(); i!=instances.end(); ++i)
- {
- const Matrix &m = *(*i)->get_matrix();
- for(unsigned j=0; j<3; ++j)
- glVertexAttrib4f(matrix_location+j, m(j, 0), m(j, 1), m(j, 2), m(j, 3));
- (*i)->render(renderer, tag);
- }
- }
+ const Technique *tech = object.get_technique();
+ if(!tech)
+ throw logic_error("no technique");
+ 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(), STREAMING);
+ instance_data.refresh();
+
+ Renderer::Push push(renderer);
+ method->apply(renderer);
+ mesh->draw_instanced(renderer, vtx_setup, instances.size());