# Polygon in GL_LINE mode: incorrect rendering when on viewport edge

## Recommended Posts

jpnascim    100
Hello everyone, I am rendering some convex polygons in GL_LINE mode. In most machines everything is rendered correctly. However, in some machines (with Intel onboard video), as soon as these polygons are moved and some of the vertexes stay outside the viewport, additional edges are drawn (as if video card is tessellating my convex polygons and showing edges as a result of this operation). In other machines with other video cards (ATI, NVIDIA), polygon is rendered correctly no matter if all of its vertexes are visible or not. For example (considering the problematic machine), for a simple convex pentagon positioned in the middle of the viewport everything is OK (I see 5 edges connecting 5 vertexes) but when I move it so 2 vertexes fall outside viewport, I see 2 additional edges drawn (from vertexes that are outside viewport to the opposite one). If I move polygon back so all vertexes are within viewport, the extra edges disappear. Please excuse me as I am unable to post a screenshot right now but I hope you get a picture. I am using the following simple sequence of commands("points" is a list of vertexes that remains unchanged during the whole process):
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
glEdgeFlag(TRUE);
// Draw the Polygon
glBegin(GL_POLYGON);

for (size_t i = 0; i < nPoints; i++ )
{
glVertex2d(points[i].x, points[i].y);
}

glEnd();



##### Share on other sites
Spynacker    106
Sounds to me like a bug in the Intel driver.
I believe it has something todo with the clipping planes
of the viewing volume. When you move parts of your polygon
outside of the viewing volume it they will be clipped which
will generate new vertices. Maybe the driver is connecting them wrong.
\           \  \             \              \           |    \          |     \         |     /         |    /          |   /          /  /          / /          //          /

As you can see in the "picture" above clipping off one vertex will result
in two new vertices.