tags:

views:

79

answers:

1

I am trying to render 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'm using homogeneous coordinates to draw triangles with two vertices at "infinity."

This code works like a charm on my computer, but a user is reporting that it doesn't render correctly on theirs: instead of an infinite half-plane they are seeing two (finite) triangles.

Is my use of w-coordinate 0 undefined behavior? Is it something that only works on some versions of OpenGL? I tried looking through the Khronos OpenGL specs but couldn't find a section where rendering of primitives with w-coordinate 0 was addressed.

+1  A: 

I tested this on my machine(nVidia Quadro) and it renders correctly. I've found code samples (for shadow volumes) that scales the W coordinate to infinity that work fine also.

I'm going to guess it's a driver issue or something external to this code?

Ron Warholic
Any word on what the issue was? Did you manage to resolve it?
Ron Warholic