0

Lets see this code:

glGenVertexArrays(1, &name);
glBindVertexArray(name);

glBindBuffer(GL_ARRAY_BUFFER, someBuffer1);
glVertexAttribPointer(...);

(...)

glBindBuffer(GL_ARRAY_BUFFER, someBuffer2);
glVertexAttribPointer(...);

(...)

glBindVertexArray(0);

What happens if I decide to do something like this:

glBindVertexArray(name);

glBindBuffer(GL_ARRAY_BUFFER, someBuffer3);
glVertexAttribPointer(...);

(...)

glBindBuffer(GL_ARRAY_BUFFER, someBuffer4);
glVertexAttribPointer(...);

(...)

glBindVertexArray(0);

? Can I change vertex declaration layout this way? Are there ways to do it?

user3808059
  • 373
  • 2
  • 15

1 Answers1

1

Yes. That's precisely why a simple solution to avoiding VAO's altogether is generating and binding a single one at program start. However, that mitigates any performance benefits you may gain -- switching VAOs is (or should be) faster than redefining the vertex layout.

Kornel Kisielewicz
  • 55,802
  • 15
  • 111
  • 149