PDA

View Full Version : Vertices list of a projection



Bougnat
10-29-2017, 11:13 AM
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

GClements
10-30-2017, 06:21 AM
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.

Dark Photon
10-30-2017, 06:30 AM
CPU: Just do the matrix product (M*V*P) for each vertex on the CPU in your app.
GPU: Use transform feedback (https://www.khronos.org/opengl/wiki/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.

Bougnat
10-30-2017, 08:14 AM
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?

GClements
10-30-2017, 11:12 AM
Assuming that you're referring to OpenGL 3+ transform-feedback mode, not the legacy feedback mode:



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?

Yes. The output is in the order the primitives are rendered. Each primitive generates 1 (points), 2 (lines) or 3 (triangles) vertices.



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?
Polygons and quads are converted to triangles.

Bougnat
11-02-2017, 01:41 AM
Thanks for your answer. :)