X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fbuffer.cpp;h=080c3fb380dc6dbf605e3a843b5ffb1e9a2851ba;hb=4a6c595b4d954b6cf69c6388a43b2b66f84d8c0a;hp=1226dbe3223f41e438ddcc7ca1c2f9b107b0fd17;hpb=57de40e1e802e44ae5b4caa67b0bb8763828b5c3;p=libs%2Fgl.git diff --git a/source/buffer.cpp b/source/buffer.cpp index 1226dbe3..080c3fb3 100644 --- a/source/buffer.cpp +++ b/source/buffer.cpp @@ -1,4 +1,5 @@ #include +#include #include "buffer.h" #include "error.h" #include "mesh.h" @@ -64,8 +65,23 @@ BufferRange *Buffer::create_range(unsigned s, unsigned o) void *Buffer::map(BufferAccess access) { - BindRestore _bind(this, type); - return glMapBuffer(type, access); + if(ARB_map_buffer_range) + { + BindRestore _bind(this, type); + GLenum access_bits = 0; + if(access==READ_ONLY) + access_bits = GL_MAP_READ_BIT; + else if(access==WRITE_ONLY) + access_bits = GL_MAP_WRITE_BIT; + else if(access==READ_WRITE) + access_bits = GL_MAP_READ_BIT|GL_MAP_WRITE_BIT; + return glMapBufferRange(type, 0, size, access_bits); + } + else + { + BindRestore _bind(this, type); + return glMapBuffer(type, access); + } } bool Buffer::unmap()