+void *Buffer::map(BufferAccess access)
+{
+ if(ARB_map_buffer_range)
+ {
+ 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;
+ if(ARB_direct_state_access)
+ return glMapNamedBufferRange(id, 0, size, access_bits);
+ else
+ {
+ BindRestore _bind(this, type);
+ return glMapBufferRange(type, 0, size, access_bits);
+ }
+ }
+ else if(ARB_direct_state_access)
+ return glMapNamedBuffer(id, access);
+ else
+ {
+ BindRestore _bind(this, type);
+ return glMapBuffer(type, access);
+ }
+}
+
+bool Buffer::unmap()
+{
+ if(ARB_direct_state_access)
+ return glUnmapNamedBuffer(id);
+ else
+ {
+ BindRestore _bind(this, type);
+ return glUnmapBuffer(type);
+ }
+}
+