X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcore%2Fbuffer.cpp;h=ed0c552360ac8fad2345236e2024d17455200334;hb=6d2e2a0bb28496a8c25b441009bdd2a1a1e72d81;hp=15a37397bcb18bdf094b5e5a5cef1a7d31b38c31;hpb=6080120777fdf7b6e1184288eff9d205ca7ebf5f;p=libs%2Fgl.git diff --git a/source/core/buffer.cpp b/source/core/buffer.cpp index 15a37397..ed0c5523 100644 --- a/source/core/buffer.cpp +++ b/source/core/buffer.cpp @@ -34,7 +34,7 @@ void Buffer::sub_data(size_t off, size_t sz, const void *d) { if(size==0) throw invalid_operation("Buffer::sub_data"); - if(off>size || off+sz>size) + if(off>get_total_size() || off%size+sz>size) throw out_of_range("Buffer::sub_data"); BufferBackend::sub_data(off, sz, d); @@ -46,5 +46,23 @@ void Buffer::require_size(size_t req_sz) const throw buffer_too_small(format("buffer has %d bytes; %d required", size, req_sz)); } +void *Buffer::map() +{ + if(!can_map() || mapped) + throw invalid_operation("Buffer::map"); + void *result = BufferBackend::map(); + mapped = true; + return result; +} + +bool Buffer::unmap() +{ + if(!can_map() || !mapped) + throw invalid_operation("Buffer::map"); + bool result = BufferBackend::unmap(); + mapped = false; + return result; +} + } // namespace GL } // namespace Msp