Jump to content
  • Advertisement
Sign in to follow this  

OpenGL glVertexAttribBinding()

This topic is 2217 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts


my question: why? what's the benefit of Example 2 ?
what's the difference of binding a buffer vs binding a buffer to a binding point ?
and is the vertex buffer binding from glBindVertexBuffer a VAO state ?

to render multiple vbo's with the same vertex layout i could use

[font=courier new,courier,monospace]glVertexAttribFormat(...)[/font]
glVertexAttribBinding(..., 0);
glVertexAttribBinding(..., 0);
glBindVertexBuffer(0,...) / draw / glBindVertexBuffer(0,...) / draw ... right ?

can i do the same with VertexAttributePointer ?
glVertexAttribPointer(...) glBindBuffer(...) draw() glBindBuffer(...) draw()

[source lang="java"]
glBindBuffer(GL_ARRAY_BUFFER, buff);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast<void*>(baseOffset + offsetof(position, Vertex)));
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), reinterpret_cast<void*>(baseOffset + offsetof(normal, Vertex)));
glVertexAttribPointer(2, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(Vertex), reinterpret_cast<void*>(baseOffset + offsetof(color, Vertex)));[/source]

[source lang="java"]
glBindVertexBuffer(0, buff, baseOffset, sizeof(sizeof(Vertex)));
glVertexAttribFormat(0, 3, GL_FLOAT, GL_FALSE, offsetof(position, Vertex));
glVertexAttribBinding(0, 0);
glVertexAttribFormat(1, 3, GL_FLOAT, GL_FALSE, offsetof(normal, Vertex));
glVertexAttribBinding(1, 0);
glVertexAttribFormat(2, 4, GL_UNSIGNED_BYTE, GL_TRUE, offsetof(color, Vertex));
glVertexAttribBinding(2, 0);[/source]

Share this post

Link to post
Share on other sites
For trivial cases where you've one vertex format per vertex buffer there's no benefit - it's just more code.

To see the benefit you should scoot over to http://www.opengl.org/registry/specs/ARB/vertex_attrib_binding.txt where the rationale behind this functionality is provided:
This extension allows the application to change the mapping between attributes and bindings, which can make it more efficient to update vertex buffer bindings for interleaved vertex formats where many attributes share the same buffer.

This extension also separates the vertex binding update from the vertex attribute format update, which saves applications the effort of redundantly specifying the same format state over and over.[/quote]

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!