Reputation: 28
I'm working on a picking function with OpenGL. I know that I can render 3 lines using glPolygonMode(GL_FRONT_AND_BACK, GL_Lines);
when the model is a triangle:
I also know that I can render 3 points using glPolygonMode(GL_FRONT_AND_BACK, GL_Points);
when the model is a triangle:
Now I'm running into this problem: I cannot find a way to render 2 endpoints when rendering a line using GL_LINES
.
Is there anything similar to glPolygonMode()
that controls how GL_LINES
works?
Upvotes: 0
Views: 1058
Reputation: 54592
As was already pointed out, there is no such thing as a glLineMode()
call that would allow you to turn lines into points with a simple state setting.
If you can change the draw calls, you can obviously use GL_POINTS
as the primitive type when you want to draw points.
Contrary to what the other answers claim, I believe there is a way to do this, even if hypothetically you can't modify the draw calls. You could use a geometry shader that has lines as the input primitive type, and points as the output primitive type. The geometry shader could look like this:
layout(lines) in;
layout(points, max_vertices = 2) out;
void main() {
gl_Position = gl_in[0].gl_Position;
EmitVertex();
gl_Position = gl_in[0].gl_Position;
EmitVertex();
EndPrimitive();
}
Upvotes: 0
Reputation: 43319
GL_LINES
describes how the primitive (triangle) is filled in this case.
You can vaguely make out the original primitive even if it is represented as a series of lines or unconnected points rather than a filled triangle. However, for lines, if you simplify them to nothing but points you loose critical information necessary to make any sense of what you are seeing (how those points were connected).
A line mode would make no sense in light of this, and the closest thing that really ever existed would probably be line stippling.
Just use GL_POINTS
as your primitive instead, you clearly do not require lines for whatever you are trying to accomplish.
Upvotes: 1
Reputation: 473407
You can render them as GL_POINTS
primitives rather than GL_LINES
. Of course, you will need to apply a point size for them to be larger more than just a single dot.
Upvotes: 0
Reputation: 162164
Is there anything similar to
glPolygonMode()
that controls howGL_LINES
works?
In one word: No. You'll have to implement this yourself (by simply submitting just the endpoints).
Upvotes: 0