VAO not working in OpenGL 4.5

I am attempting to convert some code from OpenGL 4.4 to OpenGL 4.5. Here is the old code which uses the DSA extension:


GLuint vao = 0;
glGenVertexArrays(1, &vao);
glBindVertexArray(vao);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buffers[2]);
glEnableVertexArrayAttribEXT(vao, 0);
glEnableVertexArrayAttribEXT(vao, 1);
glVertexArrayVertexAttribOffsetEXT(vao, buffers[0], 0, 3, GL_FLOAT, GL_FALSE, 0, 0);
glVertexArrayVertexAttribOffsetEXT(vao, buffers[1], 1, 2, GL_FLOAT, GL_FALSE, 0, 0);

Here is the new code which uses core DSA:


GLuint vao = 0;
glCreateVertexArrays(1, &vao);
glVertexArrayElementBuffer(vao, buffers[2]);
glEnableVertexArrayAttrib(vao, 0);
glEnableVertexArrayAttrib(vao, 1);
glVertexArrayVertexBuffer(vao, 0, buffers[0], 0, 0);
glVertexArrayVertexBuffer(vao, 1, buffers[1], 0, 0);
glVertexArrayAttribFormat(vao, 0, 3, GL_FLOAT, GL_FALSE, 0);
glVertexArrayAttribFormat(vao, 1, 2, GL_FLOAT, GL_FALSE, 0);

This code does not work and I am not sure why. Nothing is rendered and no errors or debug output is generated.

Second question: Is the relativeoffset of glVertexArrayAttribLFormat identical to the stride of glVertexArrayVertexBuffer? It seems odd to have to specify the same exact thing twice in a row.

Try to set a stride to a proper value, not 0.

Stride 0 has always been valid in OpenGL for specifying tightly-packed data.

If the stride was 0 in the first version then why would I want to change it? What’s improper about a stride of 0? The attributes are coming from separate buffers filled with packed floats. What stride would you recommend for that?

[QUOTE=Chris_F;1261553]If the stride was 0 in the first version then why would I want to change it? What’s improper about a stride of 0? The attributes are coming from separate buffers filled with packed floats. What stride would you recommend for that?[/QUOTE]That is true, I remember. But try to find the mention of that in the new specs:
http://www.opengl.org/sdk/docs/man4/html/glVertexAttribFormat.xhtml
I don’t see a note about special value 0. Therefore, use relativeoffset=8 for tightly packed float2 and 12 for float3. Just try - it wouldn’t hurt, right?

It works with an explicit stride. It seems that one of the side effects of separating buffer binding from vertex attribute specification is that it can no longer automatically calculate the stride.