Using OpenGL's gluLookAt() to move the camera/eye backwards

Tag: opengl Author: biranchuanshuo Date: 2011-02-26

I'm trying to use gluLookAt to move to another part of the scene. It's turning my model into a flat line though. My function call is below:

gluLookAt(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, -5.0f, 0.0f, 0.0f, 0.0f);

Best Answer

You need a nonzero up vector: the last three arguments must not all be zero. For example, if the y axis points up in your coordinate system:

gluLookAt(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, -5.0f, 0.0f, 1.0f, 0.0f);
                                                     ^^^^

comments:

As it turns out, I didn't need to use gluLookAt() anwyay, but thanks! Right now I have to rotate my model/scene around. EDIT: I just got it! Thanks!