I am trying to make a two-dimensional half-plane in OpenGL with the following code:
void renderHalfplane(double *x, double *n)
{
glPushMatrix();
double theta = -360.0 * atan2(n[0], n[1])/(2.0*PI);
glTranslated(x[0], x[1], 0);
glRotated(theta, 0, 0, 1.0);
glBegin(GL_TRIANGLES);
glVertex4d(0.0, 0.0, 0.0, 1.0);
glVertex4d(1.0, 0.0, 0.0, 0.0);
glVertex4d(0.0,-1.0, 0.0, 0.0);
glVertex4d(0.0, 0.0, 0.0, 1,0);
glVertex4d(-1.0,0.0, 0.0, 0.0);
glVertex4d(0.0,-1.0, 0.0, 0.0);
glEnd();
glPopMatrix();
}
Here I use homogeneous coordinates to draw triangles with two vertices at “infinity”.
This code works like a charm on my computer, but the user reports that he does not correctly display them: instead of an infinite half-plane, they see two (final) triangles.
Am I using the w coordinate 0 undefined behavior? Is this something that only works on some versions of OpenGL? I tried to look at the Hronos OpenGL specifications, but could not find a section in which rendering of primitives with a w-coordinate of 0 was processed.