]> git.tdb.fi Git - libs/gl.git/blobdiff - source/buffer.cpp
Move srgb handling to storage_pixelformat_from_graphics
[libs/gl.git] / source / buffer.cpp
index 066ab96c5919b2c154879224323f704662ce2e14..080c3fb380dc6dbf605e3a843b5ffb1e9a2851ba 100644 (file)
@@ -1,7 +1,5 @@
 #include <stdexcept>
-#include <msp/gl/extensions/arb_pixel_buffer_object.h>
-#include <msp/gl/extensions/arb_uniform_buffer_object.h>
-#include <msp/gl/extensions/arb_vertex_buffer_object.h>
+#include <msp/gl/extensions/arb_map_buffer_range.h>
 #include "buffer.h"
 #include "error.h"
 #include "mesh.h"
@@ -67,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()