GL_LINES are not visible when camera direction is colinear with the line vector( actually it should look like a point)

when lines are drawn through GL_LINES… the visualization is good.
But when the lines are falling in the camera direction they are not visible.
Actually they must be visible like a point of line width.
For your understanding… in the below… the left one is the line and the right one camera

------------------ <--------(camera direction)

In the above it should look like a point… but its completely invisible.
Can anyone suggest the solution for this…

Thanks in advance

The rasterizer does the correct thing. The line’s both ends have the exact same XY, so it has length zero. Degenerate shapes (triangles with area zero, or lines with length zero) are to generate no pixels. If you want your line to render in such circumstances, make it a manifold out of triangles. (This will also give you better control of the way it looks.)

1 Like

More precisely: if both endpoints lie within the same pixel, and the second endpoint lies within a diamond inscribed within that pixel, nothing will be rendered.

The rasterisation algorithm for lines has the property that for line strips where multiple consecutive vertices fall within the same pixel, that pixel will be rendered at most once. This is necessary to ensure that blending and glLogicOp(GL_XOR) (and GL_EQUIV) behave as expected.

The precise details of line rasterisation are given in §14.5.1 “Basic Line Segment Rasterization” of the OpenGL 4.6 specification.

In this particular case, this will probably just result in a zero-area triangle, which also won’t be rendered. Even rendering a line as a long, thin cuboid may not work if the cap gets clipped away by the near plane.

The most robust solution is to render a point on the line at a position between the near and far planes. This requires either adjusting the point’s position based upon the viewpoint, or rendering points at regular intervals so that at least one will survive clipping.

More precisely: if both endpoints lie within the same pixel, and the second endpoint lies within a diamond inscribed within that pixel, nothing will be rendered.

Thanks. I wasn’t sure of the precise rules.

In this particular case, this will probably just result in a zero-area triangle, which also won’t be rendered.

Yes. A thin long cuboid (or any prism) was more akin to what I was describing. If we wind the triangles to face them inward (or disable backface culling altogether), this should always draw something, provided perspective projection is being applied. The absence of perspective projection probably calls for solutions like yours, repeating a point (or the caps) midway.