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.
43 static const Buffer *bound[4];
50 static void require_buffer_type(BufferType);
53 /** Sets the usage hint of the buffer. It will take effect the next time
54 the buffer's contents are defined. */
55 void set_usage(BufferUsage);
57 /** Uploads data into the buffer, completely replacing any previous
59 void data(unsigned, const void *);
61 /** Overwrites part of the buffer data with new data. The buffer size can
62 not be changed with this call. */
63 void sub_data(unsigned, unsigned, const void *);
65 unsigned get_size() const { return size; }
67 /** Binds the buffer in its default slot. */
68 void bind() const { bind_to(type); }
70 /** Binds the buffer in an alternate slot. */
71 void bind_to(BufferType) const;
73 /** Unbinds the buffer from its default slot. */
74 void unbind() const { unbind_from(type); }
76 static const Buffer *current(BufferType t) { return binding(t); }
77 static void unbind_from(BufferType);
79 static const Buffer *&binding(BufferType);
80 static bool set_current(BufferType, const Buffer *);
81 static void restore(const Buffer *, BufferType);
85 An adaptor for Buffer to make it compatible with Bind.
87 template<BufferType T>
94 BufferAlias(const Buffer &b): buffer(b) { }
96 void bind() const { buffer.bind_to(T); }
97 static const Buffer *current() { return Buffer::current(T); }
98 static void unbind() { Buffer::unbind_from(T); }