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() { }
19 A buffer for storing data in GL memory. Putting vertex and index data in
20 buffers can improve rendering performance. The VertexArray, Mesh and
21 UniformBlock classes contain built-in support for buffers.
23 class Buffer: public BufferBackend
31 /** Defines the storage size of the buffer. Must be called before data can
32 be uploaded. Storage cannot be changed once set. */
33 void storage(std::size_t);
35 /** Uploads data into the buffer, completely replacing any previous
36 contents. Storage must be defined beforehand. The data must have size
37 matching the defined storage. */
38 void data(const void *);
40 /** Overwrites part of the buffer data with new data. Storage must be
41 defined beforehand. */
42 void sub_data(std::size_t, std::size_t, const void *);
44 std::size_t get_size() const { return size; }
46 void require_size(std::size_t) const;
48 using BufferBackend::map;
49 using BufferBackend::unmap;
51 using BufferBackend::set_debug_name;