gluLookAt glitch

Tag: opengl , glulookat Author: chengyihan Date: 2012-11-18

I drew an object consisting of 2 tangent spheres, which is itself tangent to a wall (schema below). Using gluLookAt(), I set the camera in x point (first sphere center), looking to y point (second sphere center), so practically I see along the wall. But then, I can see a bit inside the wall (some of ']'s).

   [ ]
(x)[ ]
(y)[ ]
   [ ]

Does anyone know what the problem could be?

Observation: if I move the spheres a bit further from the wall, the glitch disappears, however I don't understand why it is present when the spheres are very close to the wall.

Best Answer

Sounds to me like it's a clipping artefact - how far away from the wall is the camera, and where is the near clip plane?

If the clip-plane is far enough out to extend into the wall, the wall will be clipped and you will see through (or into) it.

comments:

That was indeed the problem. Now, I set a smaller zNear parameter to gluPerspective().