The call to glBindBuffer
tells OpenGL to use vertexBufferObject
whenever it needs the GL_ARRAY_BUFFER
.
glEnableVertexAttribArray
means that you want OpenGL to use vertex attribute arrays; without this call the data you supplied will be ignored.
glVertexAttribPointer
, as you said, tells OpenGL what to do with the supplied array data, since OpenGL doesn't inherently know what format that data will be in.
glDrawArrays
uses all of the above data to draw points.
Remember that OpenGL is a big state machine. Most calls to OpenGL functions modify a global state that you can't directly access. That's why the code ends with glDisableVertexAttribArray
and glBindBuffer(..., 0)
: you have to put that global state back when you're done using it.