View Full Version : limits of gluLookAt

06-14-2010, 06:54 AM
Hello all,

I have a problem with

gluLookAt(v3dEye.x, v3dEye.y, v3dEye.z, // eye position
v3dView.x, v3dView.y, v3dView.z, // look at position
0.0f, 1.0f, 0.0f); // z-up vector

I use it to set my camera and it work well.
But if I look from
top (e.g. v3dView=(0,0,0) and v3dEye(0, 1, 0)
or from bottom (e.g. v3dView=(0,0,0) and v3dEye(0, -1, 0)
the scene crashes (the screen just became black).

Is there a limitation of the function gluLookAt?
If so, how can I create a top/bottom view of the scene?

thank you very much

06-14-2010, 07:42 AM
Set the up vector in the direction you want the top of the screen to point, otherwise the matrix math messes up a bit when looking along the up/down vector.

06-14-2010, 08:00 AM
gluLookAt probably fails when the up vector and the look direction are colinear. So, in your case, try making the up vector: (1.0, 0.0, 0.0)

Good old gimbal lock!!