I give up on that mysterious VAO - but here is a modified version.
First the global vars. The glCreate...() can give more than one ID, and the idea is to have more than one buffer.
/* GL objects/binds/targets
'VB' is vertex buffer [binding point index]
'GVAA0' is generic vertex array attribute "0" = first 'in' of vertex shader */
int BUF[3];
int VB[16];
const int GVAA0 = 0;
The buffer setup function with "official" description in comments.
void
init_bufs_format46(void) {
/* New Buffer, with unspecified target */
glCreateBuffers(1, BUF);
/* New Data Store for Buffer Object */
glNamedBufferData(BUF[0], sizeof vertices, vertices, GL_STATIC_DRAW);
/* fresh ID for Vertex Buffer */
glCreateVertexArrays(1, VB);
/* Bind a vertex buffer bind point to a buffer | Attach Buffer to Vertex Array */
glBindVertexBuffer(VB[0], BUF[0], 0, 5*sizeof(float)); //..., offset, stride)
glVertexAttribFormat(GVAA0, 4, GL_FLOAT, 0, 1*sizeof(float)); // ..., reloffset) -> skip first float
glEnableVertexAttribArray(GVAA0);
}
Now glCreateVertexArrays() reserves an ID. Before it was a value "3" picked at random. I hope there is no problem with VAO vs. VBO here.
The last step is now:
/* Associate Vertex Attribute and Vertex Buffer Binding */
glVertexAttribBinding(GVAA0, VB[0]);
better than (0, id).
VBO (Vertex Buffer Object)
This (and not VAO) is the main source of vertex data according to the 2019 specs of the "OpenGL Graphics System".
The specs themselves do not explain very much (or too much:). But this front cover is very well made.
