Hi,
I want to know how can I get my data back from a Buffer.
Actually, I’m making use of a vertex shader that draws result into a transformfeedbackbuffer.
Now I want to get my data that is in the transformfeedbackbuffer to check if it is doing the right compuation.
In the initialization I create an update_vao:
glBindVertexArray(update_vao[0]);
glBindBuffer(GL_ARRAY_BUFFER, position[0]);
glBufferData(GL_ARRAY_BUFFER, 3*positions.size() * sizeof(GL_FLOAT), positions.constData(), GL_DYNAMIC_COPY);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, NULL);
glBindBuffer(GL_ARRAY_BUFFER, velocity[0]);
glBufferData(GL_ARRAY_BUFFER, 3*velocities.size() * sizeof(GL_FLOAT), velocities.constData(), GL_DYNAMIC_COPY);
glEnableVertexAttribArray(1);
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, NULL);
In the Paint part I do this :
// Write to second
glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, position[1]);
//
//
glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 1, velocity[1]);
}
// Turn off rasterization for the simulation pass (no fragment shader)
glEnable(GL_RASTERIZER_DISCARD);
// Press record...
glBeginTransformFeedback(GL_POINTS);
// Draw
glDrawArrays(GL_POINTS, 0, positions.size());
// Press stop...
glEndTransformFeedback();
When I’m done I want to get what was drawn in the position[1] and velocity[1],
How can I do that, I tried whith glMapBuffer but I have exceptions (Memory Acces)