3 This file is part of libmspgl
4 Copyright © 2007 Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
8 #ifndef MSP_GL_BUFFER_H_
9 #define MSP_GL_BUFFER_H_
18 ARRAY_BUFFER = GL_ARRAY_BUFFER_ARB,
19 ELEMENT_ARRAY_BUFFER = GL_ELEMENT_ARRAY_BUFFER_ARB,
20 PIXEL_PACK_BUFFER = GL_PIXEL_PACK_BUFFER_ARB,
21 PIXEL_UNPACK_BUFFER = GL_PIXEL_UNPACK_BUFFER_ARB
26 STREAM_DRAW = GL_STREAM_DRAW_ARB,
27 STREAM_READ = GL_STREAM_READ_ARB,
28 STREAM_COPY = GL_STREAM_COPY_ARB,
29 STATIC_DRAW = GL_STATIC_DRAW_ARB,
30 STATIC_READ = GL_STATIC_READ_ARB,
31 STATIC_COPY = GL_STATIC_COPY_ARB,
32 DYNAMIC_DRAW = GL_DYNAMIC_DRAW_ARB,
33 DYNAMIC_READ = GL_DYNAMIC_READ_ARB,
34 DYNAMIC_COPY = GL_DYNAMIC_COPY_ARB
38 A buffer for storing data in GL memory. Putting vertex and index data in
39 buffers can improve rendering performance. The VertexArray and Mesh classes
40 contain built-in support for buffers.
49 static const Buffer *bound[4];
55 /** Binds the buffer in its default slot. */
56 void bind() const { bind(type); }
58 /** Binds the buffer in an alternate slot. */
59 void bind(BufferType) const;
62 void maybe_bind() const;
65 /** Unbinds the buffer from its default slot. */
66 void unbind() const { unbind(type); }
68 /** Sets the usage hint of the buffer. It will take effect the next time
69 the buffer's contents are defined. */
70 void set_usage(BufferUsage);
72 /** Uploads data into the buffer, completely replacing any previous
74 void data(unsigned, const void *);
76 /** Overwrites part of the buffer data with new data. The buffer size can
77 not be changed with this call. */
78 void sub_data(unsigned, unsigned, const void *);
80 static void unbind(BufferType);
82 static const Buffer *&binding(BufferType);