#ifndef MSP_GL_BUFFER_H_
#define MSP_GL_BUFFER_H_
+#include <stdexcept>
+#include <string>
#include <vector>
#include "gl.h"
+#include <msp/gl/extensions/arb_pixel_buffer_object.h>
#include <msp/gl/extensions/arb_vertex_buffer_object.h>
#include <msp/gl/extensions/arb_uniform_buffer_object.h>
+#include <msp/gl/extensions/oes_mapbuffer.h>
namespace Msp {
namespace GL {
+class buffer_too_small: public std::logic_error
+{
+public:
+ buffer_too_small(const std::string &w): std::logic_error(w) { }
+ virtual ~buffer_too_small() throw() { }
+};
+
enum BufferType
{
ARRAY_BUFFER = GL_ARRAY_BUFFER,
DYNAMIC_COPY = GL_DYNAMIC_COPY
};
+enum BufferAccess
+{
+ READ_ONLY = GL_READ_ONLY,
+ WRITE_ONLY = GL_WRITE_ONLY,
+ READ_WRITE = GL_READ_WRITE
+};
+
class BufferRange;
/**
unsigned get_size() const { return size; }
+ void require_size(unsigned) const;
+
BufferRange *create_range(unsigned, unsigned);
+ void *map(BufferAccess);
+ bool unmap();
+
/** Binds the buffer in its default slot. */
void bind() const { bind_to(type); }
public:
BufferRange(Buffer &, unsigned, unsigned);
+ ~BufferRange();
void data(const void *);