1 #ifndef MSP_GL_BUFFER_H_
2 #define MSP_GL_BUFFER_H_
11 ARRAY_BUFFER = GL_ARRAY_BUFFER_ARB,
12 ELEMENT_ARRAY_BUFFER = GL_ELEMENT_ARRAY_BUFFER_ARB,
13 PIXEL_PACK_BUFFER = GL_PIXEL_PACK_BUFFER_ARB,
14 PIXEL_UNPACK_BUFFER = GL_PIXEL_UNPACK_BUFFER_ARB
19 STREAM_DRAW = GL_STREAM_DRAW_ARB,
20 STREAM_READ = GL_STREAM_READ_ARB,
21 STREAM_COPY = GL_STREAM_COPY_ARB,
22 STATIC_DRAW = GL_STATIC_DRAW_ARB,
23 STATIC_READ = GL_STATIC_READ_ARB,
24 STATIC_COPY = GL_STATIC_COPY_ARB,
25 DYNAMIC_DRAW = GL_DYNAMIC_DRAW_ARB,
26 DYNAMIC_READ = GL_DYNAMIC_READ_ARB,
27 DYNAMIC_COPY = GL_DYNAMIC_COPY_ARB
31 A buffer for storing data in GL memory. Putting vertex and index data in
32 buffers can improve rendering performance. The VertexArray and Mesh classes
33 contain built-in support for buffers.
42 static const Buffer *bound[4];
49 const Buffer *maybe_bind() const;
52 /** Sets the usage hint of the buffer. It will take effect the next time
53 the buffer's contents are defined. */
54 void set_usage(BufferUsage);
56 /** Uploads data into the buffer, completely replacing any previous
58 void data(unsigned, const void *);
60 /** Overwrites part of the buffer data with new data. The buffer size can
61 not be changed with this call. */
62 void sub_data(unsigned, unsigned, const void *);
64 /** Binds the buffer in its default slot. */
65 void bind() const { bind_to(type); }
67 /** Binds the buffer in an alternate slot. */
68 void bind_to(BufferType) const;
70 /** Unbinds the buffer from its default slot. */
71 void unbind() const { unbind_from(type); }
73 static const Buffer *current(BufferType t) { return binding(t); }
74 static void unbind_from(BufferType);
76 static const Buffer *&binding(BufferType);
77 static void restore(const Buffer *, BufferType);
81 An adaptor for Buffer to make it compatible with Bind.
83 template<BufferType T>
90 BufferAlias(const Buffer &b): buffer(b) { }
92 void bind() const { buffer.bind_to(T); }
93 static const Buffer *current() { return Buffer::current(T); }
94 static void unbind() { Buffer::unbind_from(T); }