1 #ifndef MSP_GL_BUFFER_H_
2 #define MSP_GL_BUFFER_H_
7 #include <msp/core/attributes.h>
9 #include <msp/gl/extensions/arb_pixel_buffer_object.h>
10 #include <msp/gl/extensions/arb_vertex_buffer_object.h>
11 #include <msp/gl/extensions/arb_uniform_buffer_object.h>
12 #include <msp/gl/extensions/oes_mapbuffer.h>
17 class buffer_too_small: public std::logic_error
20 buffer_too_small(const std::string &w): std::logic_error(w) { }
21 virtual ~buffer_too_small() throw() { }
26 STREAM_DRAW = GL_STREAM_DRAW,
27 STREAM_READ = GL_STREAM_READ,
28 STREAM_COPY = GL_STREAM_COPY,
29 STATIC_DRAW = GL_STATIC_DRAW,
30 STATIC_READ = GL_STATIC_READ,
31 STATIC_COPY = GL_STATIC_COPY,
32 DYNAMIC_DRAW = GL_DYNAMIC_DRAW,
33 DYNAMIC_READ = GL_DYNAMIC_READ,
34 DYNAMIC_COPY = GL_DYNAMIC_COPY
39 READ_ONLY = GL_READ_ONLY,
40 WRITE_ONLY = GL_WRITE_ONLY,
41 READ_WRITE = GL_READ_WRITE
47 A buffer for storing data in GL memory. Putting vertex and index data in
48 buffers can improve rendering performance. The VertexArray, Mesh and
49 UniformBlock classes contain built-in support for buffers.
53 friend class BufferRange;
64 /** Returns the OpenGL ID of the buffer. For internal use only. */
65 unsigned get_id() const { return id; }
67 /** Defines the storage size of the buffer. Must be called before data can
68 be uploaded. Storage cannot be changed once set. */
69 void storage(unsigned);
71 /** Allocates storage for the buffer. The contents are initially undefined.
72 If storage has already been allocated, does nothing. */
75 /** Sets the usage hint of the buffer. It will take effect the next time
76 the buffer's contents are defined. */
77 DEPRECATED void set_usage(BufferUsage);
79 /** Uploads data into the buffer, completely replacing any previous
80 contents. Storage must be defined beforehand. The data must have size
81 matching the defined storage. */
82 void data(const void *);
84 DEPRECATED void data(unsigned, const void *);
86 /** Overwrites part of the buffer data with new data. Storage must be
87 defined beforehand. */
88 void sub_data(unsigned, unsigned, const void *);
90 unsigned get_size() const { return size; }
92 void require_size(unsigned) const;
95 DEPRECATED void *map(BufferAccess) { return map(); }
98 void set_debug_name(const std::string &);