-void Batch::use_index_buffer(Buffer *buf, Batch *prev)
-{
- if(buf && prev && prev->ibuf!=buf)
- throw invalid_argument("Batch::use_index_buffer");
-
- if(!buf)
- {
- prev = 0;
- unlink_from_ibuf();
- }
-
- ibuf = buf;
- prev_in_ibuf = prev;
- next_in_ibuf = 0;
- if(prev)
- {
- prev->next_in_ibuf = this;
- ibuf_offset = prev->ibuf_offset+prev->data.size();
- }
- else
- ibuf_offset = 0;
-
- dirty = true;
-}
-
-void Batch::unlink_from_ibuf()
-{
- if(next_in_ibuf)
- next_in_ibuf->prev_in_ibuf = prev_in_ibuf;
- if(prev_in_ibuf)
- {
- prev_in_ibuf->next_in_ibuf = next_in_ibuf;
- prev_in_ibuf->update_ibuf_offsets();
- }
- else if(next_in_ibuf)
- {
- next_in_ibuf->ibuf_offset = 0;
- next_in_ibuf->update_ibuf_offsets();
- }
-}
-
-void Batch::update_ibuf_offsets()
-{
- for(Batch *b=this; b->next_in_ibuf; b=b->next_in_ibuf)
- b->next_in_ibuf->ibuf_offset = b->ibuf_offset+b->data.size();
-}
-