data.push_back(i);
}
-void Batch::upload_data() const
-{
- get_buffer()->sub_data(get_offset(), data.size(), &data[0]);
-}
-
unsigned Batch::get_index_size() const
{
if(data_type==UNSIGNED_SHORT)
restart_index = 0;
}
- if(Buffer *ibuf = get_buffer())
+ Buffer *ibuf = get_buffer();
+ BindRestore _bind_ibuf(ibuf, ELEMENT_ARRAY_BUFFER);
+ if(ibuf)
{
- bool have_vao = Mesh::current();
- const Buffer *old_ibuf = 0;
- if(!have_vao)
- {
- old_ibuf = Buffer::current(ELEMENT_ARRAY_BUFFER);
- ibuf->bind_to(ELEMENT_ARRAY_BUFFER);
- }
-
if(dirty)
update_buffer();
glDrawRangeElements(prim_type, min_index, max_index, size(), data_type, reinterpret_cast<void *>(get_offset()));
- if(!have_vao)
- {
- if(old_ibuf)
- old_ibuf->bind_to(ELEMENT_ARRAY_BUFFER);
- else
- Buffer::unbind_from(ELEMENT_ARRAY_BUFFER);
- }
}
else
glDrawRangeElements(prim_type, min_index, max_index, size(), data_type, &data[0]);