Looking at this question from 2010, concerning vertex buffers in modern OpenGL, is it still the case that Direct State Access is unavailable with them? I've modified most of my graphics library to use DSA with framebuffer, texture and so on but I still need to "bind" to set my vertex array state (bind array, bind index buffer, bind vertex buffer, unbind array, etc.).
Update 1: I had trouble understanding what the parameters do from BDL's answer. My unit test for a very simple vertex buffer (one attribute, a position) gives me a blank screen (it worked fine with the old method of describing vertex streams). It's supposed to just draw a single triangle, no index buffers required.
Here's what I'm doing, the comments are my understanding:
::glEnableVertexArrayAttrib(vao, // VAO name.
0); // Attribute index (layout in shader).
::glVertexArrayVertexBuffer(vao, // VAO name.
0, // Binding point.
vbo, // VBO name.
12, // Stride (bytes).
0); // Offset (bytes).
::glVertexArrayAttribFormat(vao, // VAO name.
0, // Attribute index (layout in shader).
3, // Component count (x,y,z).
GL_FLOAT, // Type.
GL_FALSE, // Normalised.
0); // Offset (bytes).
::glVertexArrayAttribBinding(vao, // VAO name.
0, // Attribute index (layout in shader).
0); // Binding point.
Now, I think I "get it" about binding points. They're an arbitrary number I can assign such that it's quick and easy for me to swap in a different set of attributes. So just using 0 here for this simple test should suffice.
I'm using glCreateBuffers to create the vbo and glCreateVertexArrays to create the vao (changed from the previous bindable style). There's no debug output (debug context is on) and every call is checked with glGetError and there are no errors reported.
Update 2: the glVertexArrayVertexBuffer stride and offset were in the wrong order. It now works.
Update 3: glVertexArrayVertexBuffer is called once, not once for each attribute in the VBO (if you have interleaved position, texture and so on).
See Question&Answers more detail:os