Hi everybody,
I would like to render some new positions into a VBO. The output of my fragment shader should be interpreted as new vertices, not as colors. The best way I guess, is to use a geometry shader using transform feedback. Every vertex of the scene should generate a new vertex at another position.
Here is some my geometry shader:
void main()
{
vec3 offset = vec3(5.0, 5.0, 5.0);
gl_Position = gl_PositionIn[0];
EmitVertex();
EndPrimitive();
gl_Position = vec4(gl_PositionIn[0].xyz + offset, 1.);
EmitVertex();
EndPrimitive();
}
My Transform Feedback-Function:
void performFeedback()
{
primitiveCount = numVertices;
glBindBufferOffsetNV(GL_TRANSFORM_FEEDBACK_BUFFER_NV, 0, buffers[1-currentBuffer], 0);
glBeginTransformFeedbackNV(GL_POINTS);
{
glEnable(GL_RASTERIZER_DISCARD_NV);
glBeginQuery(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_NV, query);
drawBuffer(buffers[currentBuffer], primitiveCount);
glEndQuery(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_NV);
glDisable(GL_RASTERIZER_DISCARD_NV);
}
glEndTransformFeedbackNV();
glGetQueryObjectuiv(query, GL_QUERY_RESULT, &primitiveCount);
currentBuffer = 1 - currentBuffer;
}
Display-Function:
...
glPushMatrix();
glRotatef(yrot, 0.0, 1.0, 0.0);
drawBuffer(buffers[currentBuffer], primitiveCount);
glPopMatrix();
glPushMatrix();
glRotatef(yrot, 0.0, 1.0, 0.0);
glUseProgram(programTF);
performFeedback();
glUseProgram(0);
glPopMatrix();
...
I hope anybody can understand my problem and maybe some tipps or a solution of this problem…
Thanks and Greetings,
Thopil