void Buffer::data(unsigned sz, const void *d)
{
- const Buffer *old = current(type);
- bind();
+ BindRestore _bind(this, type);
glBufferData(type, sz, d, usage);
size = sz;
- restore(old, type);
}
void Buffer::sub_data(unsigned off, unsigned sz, const void *d)
{
- const Buffer *old = current(type);
- bind();
+ BindRestore _bind(this, type);
glBufferSubData(type, off, sz, d);
- restore(old, type);
}
BufferRange *Buffer::create_range(unsigned s, unsigned o)
return true;
}
-void Buffer::restore(const Buffer *buf, BufferType type)
-{
- if(buf!=current(type))
- {
- if(buf)
- buf->bind_to(type);
- else
- unbind_from(type);
- }
-}
-
vector<const BufferRange *> BufferRange::bound_uniform;