summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
6dc5c41)
If ABR_buffer_storage is not supported, calling storage() and then
sub_data() did not result in the buffer being allocated.
Buffer::Buffer(BufferType t):
type(t),
Buffer::Buffer(BufferType t):
type(t),
+ size(0),
+ allocated(false)
{
require_buffer_type(type);
{
require_buffer_type(type);
throw invalid_argument("Buffer::storage");
size = sz;
throw invalid_argument("Buffer::storage");
size = sz;
+}
+
+void Buffer::allocate()
+{
+ if(size==0)
+ throw invalid_operation("Buffer::allocate");
+ if(allocated)
+ return;
+
if(ARB_buffer_storage)
{
static const int flags = GL_MAP_READ_BIT|GL_MAP_WRITE_BIT|GL_DYNAMIC_STORAGE_BIT;
if(ARB_buffer_storage)
{
static const int flags = GL_MAP_READ_BIT|GL_MAP_WRITE_BIT|GL_DYNAMIC_STORAGE_BIT;
BindRestore _bind(this, type);
glBufferStorage(type, size, 0, flags);
}
BindRestore _bind(this, type);
glBufferStorage(type, size, 0, flags);
}
}
void Buffer::set_usage(BufferUsage)
}
void Buffer::set_usage(BufferUsage)
BindRestore _bind(this, type);
glBufferData(type, size, d, STATIC_DRAW);
}
BindRestore _bind(this, type);
glBufferData(type, size, d, STATIC_DRAW);
}
}
void Buffer::data(unsigned sz, const void *d)
}
void Buffer::data(unsigned sz, const void *d)
void Buffer::sub_data(unsigned off, unsigned sz, const void *d)
{
void Buffer::sub_data(unsigned off, unsigned sz, const void *d)
{
+ if(size==0)
+ throw invalid_operation("Buffer::sub_data");
+
+ allocate();
+
if(ARB_direct_state_access)
glNamedBufferSubData(id, off, sz, d);
else
if(ARB_direct_state_access)
glNamedBufferSubData(id, off, sz, d);
else
BufferType type;
unsigned id;
unsigned size;
BufferType type;
unsigned id;
unsigned size;
static const Buffer *bound[5];
static const Buffer *bound[5];
be uploaded. Storage cannot be changed once set. */
void storage(unsigned);
be uploaded. Storage cannot be changed once set. */
void storage(unsigned);
+ /** Allocates storage for the buffer. The contents are initially undefined.
+ If storage has already been allocated, does nothing. */
+ void allocate();
+
/** Sets the usage hint of the buffer. It will take effect the next time
the buffer's contents are defined. */
DEPRECATED void set_usage(BufferUsage);
/** Sets the usage hint of the buffer. It will take effect the next time
the buffer's contents are defined. */
DEPRECATED void set_usage(BufferUsage);