35 return const_cast<GLvoid *
>(
pointer);
45 glEnableClientState(GL_VERTEX_ARRAY);
51 glEnableClientState(GL_NORMAL_ARRAY);
56 glEnableClientState(GL_COLOR_ARRAY);
63 glEnableClientState(GL_TEXTURE_COORD_ARRAY);
72 glDisableClientState(GL_VERTEX_ARRAY);
76 glDisableClientState(GL_NORMAL_ARRAY);
80 glDisableClientState(GL_COLOR_ARRAY);
86 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
127 std::vector<VertexAttrib>::const_iterator src = other.
_decl.begin();
128 std::vector<VertexAttrib>::iterator dest =
_decl.begin();
129 while ((src != other.
_decl.end()) && (dest !=
_decl.end())) {
130 const byte *ptr =
_data + (
reinterpret_cast<const byte *
>(src->pointer) - other.
_data);
132 dest->pointer =
reinterpret_cast<const GLvoid *
>(ptr);
159 case GL_UNSIGNED_BYTE:
162 case GL_UNSIGNED_SHORT:
168 case GL_UNSIGNED_INT:
184 for (VertexDecl::iterator a = decl.begin(); a != decl.end(); ++a)
190 for (VertexDecl::iterator a = decl.begin(); a != decl.end(); ++a) {
194 data += vertCount * a->size *
getTypeSize(a->type);
202 for (VertexDecl::iterator a = decl.begin(); a != decl.end(); ++a)
208 for (VertexDecl::iterator a = decl.begin(); a != decl.end(); ++a) {
209 a->stride = vertSize;
210 a->pointer =
_data + offset;
218 return static_cast<GLvoid *
>(
_data);
222 return static_cast<const GLvoid *
>(
_data);
226 assert(vertexDecl <
_decl.size());
228 return _decl[vertexDecl].getData();
232 assert(vertexDecl <
_decl.size());
234 return _decl[vertexDecl].getData();
256 glGenBuffers(1, &
_vbo);
257 glBindBuffer(GL_ARRAY_BUFFER,
_vbo);
259 glBindBuffer(GL_ARRAY_BUFFER, 0);
265 glBindBuffer(GL_ARRAY_BUFFER,
_vbo);
267 glBindBuffer(GL_ARRAY_BUFFER, 0);
277 glDeleteBuffers(1, &
_vbo);
290 for (VertexDecl::const_iterator d =
_decl.begin(); d !=
_decl.end(); ++d)
295 for (VertexDecl::const_iterator d =
_decl.begin(); d !=
_decl.end(); ++d)
GLvoid * getData()
Access buffer data.
Vertex texture coordinates, VTCOORDi = VTCOORD + i.
uint32 getCount() const
Get vertex count.
uint32 _size
Size of a buffer element in bytes (vertex attributes size sum).
GLuint index
Index of the vertex attribute (see VertexAttribIdEnum).
GLuint _vbo
Vertex Buffer Object.
GLenum type
Data type of each attribute component in the array.
void updateGLBound() const
Update an existing GL buffer object, assuming it is already bound.
void setVertexDeclInterleave(uint32 vertCount, VertexDecl &decl)
Set the interleaved vertex declaration for this buffer.
void setVertexDecl(const VertexDecl &decl)
Set vertex declaration for this buffer.
const GLvoid * pointer
Offset of the first component of the first generic vertex attribute.
std::vector< VertexAttrib > VertexDecl
Vertex data layout.
const VertexDecl & getVertexDecl() const
Access vertex declaration.
static uint32 getTypeSize(GLenum type)
void destroyGL()
Clear (destroy) GL resources associated with the buffer.
void setVertexDeclLinear(uint32 vertCount, VertexDecl &decl)
Set the linear vertex declaration for this buffer.
uint32 getSize() const
Get vertex element size in bytes.
Buffer containing vertex data.
GLenum getType() const
Get element type.
GLuint _hint
GL hint for static or dynamic data.
uint32 getCount() const
Get element count.
VertexDecl _decl
Vertex declaration.
GLint size
Number of components per vertex attribute, must be 1, 2, 3, 4.
VertexBuffer & operator=(const VertexBuffer &other)
GLvoid * getData()
Access buffer data.
uint32 _count
Number of elements in buffer.
void draw(GLenum mode, const IndexBuffer &indexBuffer) const
Draw this IndexBuffer/VertexBuffer combination.
Buffer containing indices data.
void initGL(GLuint hint=GL_STATIC_DRAW)
Initialise internal buffer object for GL handling.
GLsizei stride
Byte offset between consecutive vertex attributes.
void updateGL()
Update existing GL buffer object.
void setSize(uint32 vertCount, uint32 vertSize)
Change buffer size.