1 #ifndef MSP_GL_BUFFER_H_
2 #define MSP_GL_BUFFER_H_
12 class buffer_too_small: public std::logic_error
15 buffer_too_small(const std::string &w): std::logic_error(w) { }
16 virtual ~buffer_too_small() throw() { }
22 A buffer for storing data in GL memory. Putting vertex and index data in
23 buffers can improve rendering performance. The VertexArray, Mesh and
24 UniformBlock classes contain built-in support for buffers.
33 static Buffer *scratch_binding;
39 /** Returns the OpenGL ID of the buffer. For internal use only. */
40 unsigned get_id() const { return id; }
42 /** Defines the storage size of the buffer. Must be called before data can
43 be uploaded. Storage cannot be changed once set. */
44 void storage(unsigned);
46 /** Allocates storage for the buffer. The contents are initially undefined.
47 If storage has already been allocated, does nothing. */
50 /** Uploads data into the buffer, completely replacing any previous
51 contents. Storage must be defined beforehand. The data must have size
52 matching the defined storage. */
53 void data(const void *);
55 /** Overwrites part of the buffer data with new data. Storage must be
56 defined beforehand. */
57 void sub_data(unsigned, unsigned, const void *);
59 unsigned get_size() const { return size; }
61 void require_size(unsigned) const;
66 void set_debug_name(const std::string &);
71 static void unbind_scratch();