1 #ifndef MSP_GL_BUFFER_H_
2 #define MSP_GL_BUFFER_H_
6 #include "buffer_backend.h"
11 class buffer_too_small: public std::logic_error
14 buffer_too_small(const std::string &w): std::logic_error(w) { }
15 virtual ~buffer_too_small() throw() { }
21 A buffer for storing data in GL memory. Putting vertex and index data in
22 buffers can improve rendering performance. The VertexArray, Mesh and
23 UniformBlock classes contain built-in support for buffers.
25 class Buffer: public BufferBackend
35 /** Defines the storage size of the buffer. Must be called before data can
36 be uploaded. Storage cannot be changed once set. */
37 void storage(unsigned);
39 /** Uploads data into the buffer, completely replacing any previous
40 contents. Storage must be defined beforehand. The data must have size
41 matching the defined storage. */
42 void data(const void *);
44 /** Overwrites part of the buffer data with new data. Storage must be
45 defined beforehand. */
46 void sub_data(unsigned, unsigned, const void *);
48 unsigned get_size() const { return size; }
50 void require_size(unsigned) const;
52 using BufferBackend::map;
53 using BufferBackend::unmap;
55 using BufferBackend::set_debug_name;