#include <stdexcept>
+#include <msp/gl/extensions/arb_map_buffer_range.h>
#include "buffer.h"
#include "error.h"
#include "mesh.h"
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()