I'm trying to set a vertex attribute array using VBOs.
The VBO is already set and now I'm with some doubts regarding how to enable my attributes array.
Let's say that my VBO ID is bufferID and, to enable this array I do:
Code :glBindBuffer( GL_ARRAY_BUFFER, bufferID ); GLint loc = glGetAttribLocation( shader.getShaderProgram(), "inTriangleID" ); glEnableClientState( GL_VERTEX_ARRAY ); glEnableVertexAttribArray( loc ); glVertexAttribPointer( loc, 1, GL_FLOAT, GL_FALSE, 0, NULL );
My question is if after the call for glVertexAttribPointer I can bind another buffer to GL_ARRAY_BUFFER.
After the above calls comes the rendering calls. Something like
Code :glPushClientAttrib( GL_CLIENT_VERTEX_ARRAY_BIT ); glBindBuffer( GL_ARRAY_BUFFER, mPositionVboID ); glVertexPointer( mVertexSize, GL_FLOAT, 0, NULL ); glEnableClientState( GL_VERTEX_ARRAY); glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, mEboID ); glDrawElements( GL_TRIANGLES, mIndices->size(), GL_UNSIGNED_INT, NULL );
As one can see, another buffer is bind to GL_ARRAY_BUFFER. This doesn't unbind the previous buffer, which was the vertex attrib buffer or does glPushClientAttrib saves the previous buffer?
How is the correct way of set a vertex attribute array using VBOs?