X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;ds=sidebyside;f=source%2Fcore%2Fbuffer.cpp;fp=source%2Fcore%2Fbuffer.cpp;h=4750846ab1dceb291a600043977f1c06f868f403;hb=f1244e29afd2a36aafc2373d485457b4cb0411ff;hp=013a136a560a2a5866ee6bf7c343b0102cf9e246;hpb=4d146fba83f1ee7b8bd2249648a66db51857730f;p=libs%2Fgl.git diff --git a/source/core/buffer.cpp b/source/core/buffer.cpp index 013a136a..4750846a 100644 --- a/source/core/buffer.cpp +++ b/source/core/buffer.cpp @@ -18,12 +18,11 @@ namespace GL { const Buffer *Buffer::bound[5] = { 0, 0, 0, 0, 0 }; BufferType buffer_types[] = { ARRAY_BUFFER, ELEMENT_ARRAY_BUFFER, PIXEL_PACK_BUFFER, PIXEL_UNPACK_BUFFER, UNIFORM_BUFFER }; -Buffer::Buffer(BufferType t): - type(t), +Buffer::Buffer(): size(0), allocated(false) { - require_buffer_type(type); + static Require _req(ARB_vertex_buffer_object); if(ARB_direct_state_access) glCreateBuffers(1, &id); @@ -76,8 +75,8 @@ void Buffer::allocate() glNamedBufferStorage(id, size, 0, flags); else { - BindRestore _bind(this, type); - glBufferStorage(type, size, 0, flags); + BindRestore _bind(this, ARRAY_BUFFER); + glBufferStorage(ARRAY_BUFFER, size, 0, flags); } allocated = true; @@ -102,8 +101,8 @@ void Buffer::data(const void *d) glNamedBufferData(id, size, d, STATIC_DRAW); else { - BindRestore _bind(this, type); - glBufferData(type, size, d, STATIC_DRAW); + BindRestore _bind(this, ARRAY_BUFFER); + glBufferData(ARRAY_BUFFER, size, d, STATIC_DRAW); } allocated = true; @@ -130,8 +129,8 @@ void Buffer::sub_data(unsigned off, unsigned sz, const void *d) glNamedBufferSubData(id, off, sz, d); else { - BindRestore _bind(this, type); - glBufferSubData(type, off, sz, d); + BindRestore _bind(this, ARRAY_BUFFER); + glBufferSubData(ARRAY_BUFFER, off, sz, d); } } @@ -155,8 +154,8 @@ void *Buffer::map() return glMapNamedBufferRange(id, 0, size, GL_MAP_READ_BIT|GL_MAP_WRITE_BIT); else { - BindRestore _bind(this, type); - return glMapBufferRange(type, 0, size, GL_MAP_READ_BIT|GL_MAP_WRITE_BIT); + BindRestore _bind(this, ARRAY_BUFFER); + return glMapBufferRange(ARRAY_BUFFER, 0, size, GL_MAP_READ_BIT|GL_MAP_WRITE_BIT); } } @@ -167,8 +166,8 @@ bool Buffer::unmap() return glUnmapNamedBuffer(id); else if(OES_mapbuffer) { - BindRestore _bind(this, type); - return glUnmapBuffer(type); + BindRestore _bind(this, ARRAY_BUFFER); + return glUnmapBuffer(ARRAY_BUFFER); } else return true; @@ -176,8 +175,7 @@ bool Buffer::unmap() void Buffer::bind_to(BufferType t) const { - if(t!=type) - require_buffer_type(t); + require_buffer_type(t); if(t==ELEMENT_ARRAY_BUFFER) if(const VertexSetup *vs = VertexSetup::current()) { @@ -265,8 +263,7 @@ void BufferRange::data(const void *d) void BufferRange::bind_to(BufferType t, unsigned i) { - if(t!=buffer.type) - Buffer::require_buffer_type(t); + Buffer::require_buffer_type(t); if(set_current(t, i, this)) { // The buffer gets bound as a side effect