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
33 /** Defines the storage size of the buffer. Must be called before data can
34 be uploaded. Storage cannot be changed once set. */
35 void storage(unsigned);
37 /** Uploads data into the buffer, completely replacing any previous
38 contents. Storage must be defined beforehand. The data must have size
39 matching the defined storage. */
40 void data(const void *);
42 /** Overwrites part of the buffer data with new data. Storage must be
43 defined beforehand. */
44 void sub_data(unsigned, unsigned, const void *);
46 unsigned get_size() const { return size; }
48 void require_size(unsigned) const;
50 using BufferBackend::map;
51 using BufferBackend::unmap;
53 using BufferBackend::set_debug_name;