Hello,
I need to do a projection of a 3d object, and get the result as a list of segments.
Is there a way to get it as we create it for the projection (with glNewList, glBegin, glVertex, glEnd, glEndList,...) ?
Thanks,
Bougnat
Printable View
Hello,
I need to do a projection of a 3d object, and get the result as a list of segments.
Is there a way to get it as we create it for the projection (with glNewList, glBegin, glVertex, glEnd, glEndList,...) ?
Thanks,
Bougnat
Feedback mode: glRenderMode(GL_FEEDBACK).
If you can rely upon OpenGL 3 support, there's transform-feedback mode (glBeginTransformFeedback() etc).
Feeback mode returns complete primitives, and includes the effects of clipping (vertices removed by clipping won't appear in the returned primitive, while vertices introduced by clipping will).
Transform-feedback mode just returns a list of vertices.
CPU: Just do the matrix product (M*V*P) for each vertex on the CPU in your app.
GPU: Use transform feedback to do effectively the same thing in a vertex shader (M*V*P) but store the transformed vertices in a GL buffer object.
The first is easier, and ideal if you need the results on the CPU anyway.
Thanks for your answers
@Dark Photon: Yes I need an easy solution, and I need the result on the CPU. But I'm look for OpenGL to take advantage of the GPU efficiency.
@GClements: Are the vertices sorted in the list? I mean, if a vertex correspond to an end of a segment, does the next vertex correspond to the other end of the same segment?
And I saw that Feedback can capture primitive of type GL_POINTS, GL_LINES, or GL_TRIANGLES. But what if we created the input list with the type of GL_POLYGONS?
Assuming that you're referring to OpenGL 3+ transform-feedback mode, not the legacy feedback mode:
Yes. The output is in the order the primitives are rendered. Each primitive generates 1 (points), 2 (lines) or 3 (triangles) vertices.
Polygons and quads are converted to triangles.
Thanks for your answer. :)