I give up on that mysterious VAO - but hereThe key to understand these historical changes in OpenGL is the "ARB Extensions Specifications". They run from #1 in 2002 to #190 in 2019; the ones I checked mostly have a modified versionuseful "Overview" intro, explaining why this ARB spec was needed.
FirstThe OpenGL wiki (khronos.org) sometimes copies parts from the global varsARBs. The ARBs also update the specs glCreate...() can give more than one ID, and(new functions) - no wonder the idea isspecs are so hard to have more than one bufferread after all these additions.
/* 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;
ARB direct_state_acces reduces the bind-to-edit actions; it defines many new calls.
The buffer setupglVertexAttribFormat is from ARB vertex_attrib_binding.
Here the function with "official"in question. I put the official function description in comments. The vertex data this time is split into a position and a color part - vertically interlaced.
void
init_bufs_format46(void) {
/* NewARB#164 Bufferdirect_state_access, with unspecified target2014 */
- New buffer glCreateBuffers(1objects, BUF);
initialized with unspecified target /*
- New Data Store for (named) Buffer Object */
glCreateBuffers(1, BUF);
glNamedBufferData(BUF[0], sizeof vertices, vertices, GL_STATIC_DRAW);
/* ARB#125 vertex_attrib_binding, 2012 /*
fresh- IDBind fora Vertexvertex Bufferbuffer */
bind point (0-15) to glCreateVertexArrays(1,a VB);
buffer
- /*Specify Bindlayout of a generic vertex bufferattribute bindarray point
to- aAssociate buffervertex |attribute Attachand Buffervertex tobuffer Vertexbinding Array[point] */
VB[1] = 1;
glBindVertexBuffer glBindVertexBuffer (VB[0]VB[1], BUF[0], 0, 5*sizeof 3*sizeof(float)); //..., offset, stride)
glVertexAttribFormat (GVAA0, 3, GL_FLOAT, 0, 0);
glVertexAttribBinding //..., offset(GVAA0, strideVB[1]);
glEnableVertexAttribArray (GVAA0);
/* GVAA "1" glVertexAttribFormatis color here; same buffer but with an offset and a different stride */
VB[2] = 2;
int buf_offset = 6*3*sizeof(GVAA0,float);
glBindVertexBuffer 4 (VB[2], GL_FLOATBUF[0], 0buf_offset, 1*sizeof4*sizeof(float));
glVertexAttribFormat (1, 3, // ... GL_FLOAT, reloffset0, 0);
glVertexAttribBinding -> skip first float
(1, VB[2]);
glEnableVertexAttribArray (GVAA01);
}
Now glCreateVertexArrays() reserves an IDThe VB(BP)s just get integers from 0 to 15. Before it was a value "3" picked at randomNo Gen- or Create-someobj. I hope there is no problem with VAO vs. VBO hereleft the "1" in the 2nd block naked; it would be GVAA1, or then GVAA_color in this case.
The last step is(The vertex shader now: has a second in, and now it just passes on both unchanged.)
float vertices[] = {
1, 1, 0.2,
-1,-1, 0.6,
-1, 1, 0.5,
//-.1,.1,.5,
0.3, -.8, .9,
0, 0.9, .1, /* Associatez=0.1 Vertex--> Attributenear andtip Vertexof Buffersecond Bindingtriangle */
-.5, glVertexAttribBinding(GVAA0-.8, VB[0]).8,
//};
//float colors[] = {
.8, .6, .1,.2,
.6, .5, .1,.2,
.9, .3, .1,.2,
.1, .9, .6,.1,
.7, .6, .7,.1,
.3, .7, .9,.1,
};
better thanARB #28 vertex_buffer_object (0, id).(2003) is also interesting:
VBO (Vertex Buffer Object)
What should this extension be called? RESOLVED: By unanimous consent among the working group members, the name was chosen to be "ARB_vertex_buffer_object". A large number of other names were considered throughout the lifetime of the proposal, especially "vertex_array_object" (originally), "buffer_object" (later on), and "memory_object" (near the end), but the name "vertex_buffer_object" was ultimately chosen.
ThisAnd vertex_array_object became #54. (and not VAOA container object) 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 muchThey probably think:). But this with a front cover is very well madelike that on the specification, explanations are not necessary.
