PDA

View Full Version : how to alternate 2 VBOs inside one VAO



Sobeit
07-29-2014, 04:41 PM
I'm trying to implement a particle system using compute shader. I have 2 vertex buffer objects set up, I need to draw them alternatively every frame. Is there a way that I can alternate them inside the vertex array object? Or do I have to explicitly bind vbo and call glVertexAttribPointer every draw? Thanks in advance.


// 2 vertex buffer objects
GLuint m_posBO1;
GLuint m_posBO2;

glBindVertexArray(m_vao);

glBindBuffer(GL_ARRAY_BUFFER, m_posBO1);
// position attribute
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);

mhagain
07-29-2014, 06:50 PM
GL_ARB_vertex_attrib_binding (https://www.opengl.org/registry/specs/ARB/vertex_attrib_binding.txt) is ideal for this kind of use case - it's just a single glBindVertexBuffer call.

Sobeit
07-30-2014, 02:05 PM
that's it. thank you