batches.back().append(b);
else
{
+ bool reallocate = (batches.size()==batches.capacity());
+ if(reallocate && ibuf)
+ {
+ for(vector<Batch>::iterator i=batches.end(); i!=batches.begin(); )
+ (--i)->use_buffer(0);
+ }
+
Batch *prev = (batches.empty() ? 0 : &batches.back());
batches.push_back(b);
if(ibuf)
- batches.back().use_buffer(ibuf, prev);
+ {
+ if(reallocate)
+ {
+ prev = 0;
+ for(vector<Batch>::iterator i=batches.begin(); i!=batches.end(); ++i)
+ {
+ i->use_buffer(ibuf, prev);
+ prev = &*i;
+ }
+ }
+ else
+ batches.back().use_buffer(ibuf, prev);
+ }
}
}
BindRestore bind_ibuf(ibuf, ELEMENT_ARRAY_BUFFER);
Bind bind_winding(winding);
- for(list<Batch>::const_iterator i=batches.begin(); i!=batches.end(); ++i)
+ for(vector<Batch>::const_iterator i=batches.begin(); i!=batches.end(); ++i)
i->draw();
}
renderer.set_mesh(this);
renderer.set_winding_test(winding);
- for(list<Batch>::const_iterator i=batches.begin(); i!=batches.end(); ++i)
+ for(vector<Batch>::const_iterator i=batches.begin(); i!=batches.end(); ++i)
renderer.draw(*i);
}
};
VertexArray vertices;
- std::list<Batch> batches;
+ std::vector<Batch> batches;
Buffer *vbuf;
Buffer *ibuf;
unsigned vao_id;
float *modify_vertex(unsigned);
void add_batch(const Batch &b);
- const std::list<Batch> &get_batches() { return batches; }
+ const std::vector<Batch> &get_batches() const { return batches; }
void set_winding(const WindingTest *);