// Create the VAOs used for the update and render passes
glGenVertexArrays(2, update_vao);
glGenVertexArrays(2, render_vao);
// Two buffers for each of position and velocity
glGenBuffers(2, position_buffer);
// Setup Update VAO 1
glBindVertexArray(update_vao[0]);
glBindBuffer(GL_ARRAY_BUFFER, position_buffer[0]);
glBufferData(GL_ARRAY_BUFFER, 2*positions.size() * sizeof(GL_FLOAT), positions.constData(), GL_DYNAMIC_COPY);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, NULL);
// Setup Update VAO 2
glBindVertexArray(update_vao[1]);
glBindBuffer(GL_ARRAY_BUFFER, position_buffer[1]);
glBufferData(GL_ARRAY_BUFFER, 2*positions.size() * sizeof(GL_FLOAT), NULL, GL_DYNAMIC_COPY);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, NULL);
// Setup Render VAOs
for (int i = 0; i < 2; i++)
{
glBindVertexArray(render_vao[i]);
glBindBuffer(GL_ARRAY_BUFFER, position_buffer[i]);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, NULL);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, elem_array);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, elements.size() * sizeof(GL_FLOAT), elements.constData(), GL_STATIC_DRAW);
}
// Setup position and velocity TBOs
glGenTextures(2, position_tbo);
// Done with VAOs
glBindVertexArray(0);
// Set up TBOs
for (int i = 0; i < 2; i++)
{
glBindTexture(GL_TEXTURE_BUFFER, position_tbo[i]);
glTexBuffer(GL_TEXTURE_BUFFER, GL_RG32F, position_buffer[i]);
}