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.
28 friend class PipelineState;
29 friend class VertexSetup;
35 static Buffer *scratch_binding;
41 /** Returns the OpenGL ID of the buffer. For internal use only. */
42 unsigned get_id() const { return id; }
44 /** Defines the storage size of the buffer. Must be called before data can
45 be uploaded. Storage cannot be changed once set. */
46 void storage(unsigned);
48 /** Uploads data into the buffer, completely replacing any previous
49 contents. Storage must be defined beforehand. The data must have size
50 matching the defined storage. */
51 void data(const void *);
53 /** Overwrites part of the buffer data with new data. Storage must be
54 defined beforehand. */
55 void sub_data(unsigned, unsigned, const void *);
57 unsigned get_size() const { return size; }
59 void require_size(unsigned) const;
64 void set_debug_name(const std::string &);
69 static void unbind_scratch();