Hello,
I’m currently using Transform Feedback and it works very fine. But I’m not sure about my full understanding of it.
In fact, I meet a problem when I want to use 2 different Transform Feedback shaders. I explain: For instance, I would like to create 2 independant system of particles.
So I declare something like that:
// For the first system of particles
GLuint Program_1_ID = glCreateProgram();
glAttachShader(Program_1_ID, VertexShader_1_ID);
const char *varyings_1[] = {"lifetime_out"};
glTransformFeedbackVaryings(Program_1_ID, 1, varyings_1, GL_SEPARATE_ATTRIBS);
glLinkProgram(ProgramID);
// For the second system of particles
GLuint Program_2_ID = glCreateProgram();
glAttachShader(Program_2_ID, VertexShader_2_ID);
const char *varyings_2[] = {"lifetime_out", "velocity_out", "angle_out"};
glTransformFeedbackVaryings(Program_2_ID, 3, varyings_2, GL_SEPARATE_ATTRIBS);
glLinkProgram(ProgramID);
And to use these TFB:
// For the first one
glUseProgram(Program_1_ID );
glBindVertexArray(vao_1);
glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, vbo_0);
glEnable(GL_RASTERIZER_DISCARD);
glBeginTransformFeedback(GL_POINTS);
glDrawArrays(GL_POINTS, 0, nb_vertices);
glEndTransformFeedback();
// For the second one
glUseProgram(Program_2_ID );
glBindVertexArray(vao_2);
glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, vbo_1);
glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 1, vbo_2);
glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 2, vbo_3);
glEnable(GL_RASTERIZER_DISCARD);
glBeginTransformFeedback(GL_POINTS);
glDrawArrays(GL_POINTS, 0, nb_vertices);
glEndTransformFeedback();
But it dosen’t work and I’m not sure to understand why.
Is it because glTransformFeedbackVaryings
affect the varyings at the same binding point to the GL_TRANSFORM_FEEDBACK
target ?
In this case, how can I do ?
Regards
William