Possible Duplicate:
How does glBufferData know which VBO to work on?
I've noticed in sample code (in an O'Reilly book) for both VBOs and render buffers that the binding is done more than once. What is the reasoning behind this? For example, you might have this at the top of an OpenGL routine:
glGenBuffers(1, &m_vertexBuffer);
glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer);
And then before doing the drawing, you do it again:
glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer);
glVertexPointer(3, GL_FLOAT, sizeof(Vertex), 0);
//on to the drawing routine
Removing either of these causes the drawing to not appear, so why does it need binding twice?
Another example first we do this:
// Create & bind the color buffer so that the caller can allocate its space.
glGenRenderbuffersOES(1, &m_colorRenderbuffer);
glBindRenderbufferOES(GL_RENDERBUFFER_OES, m_colorRenderbuffer);
Then, after creating vertices, etc, we later we do it again:
// Bind the color buffer for rendering.
glBindRenderbufferOES(GL_RENDERBUFFER_OES, m_colorRenderbuffer);