gluLookAt

I don't know how to use the gluLookAt function, I tried some stuff, but I got weird effects...
If someone knows what are the parameters, and how to use the function, it would be nice to post a reply.
Thanx

Comments

  • void gluLookAt(
    GLdouble eyex, //
    GLdouble eyey, //The position of the eye point.
    GLdouble eyez, //
    GLdouble centerx, //
    GLdouble centery, //The reference point.
    GLdouble centerz, //
    GLdouble upx, //
    GLdouble upy, //The direction of the up vector.
    GLdouble upz //
    );

    you might use it like this
    gluLookAt(Player->position.x, Player->position.y,
    Player->position.z,LookAt.x, LookAt.y, LookAt.z,0.0, 1.0, 0.0);
    (Keeps the "camera" following the player and has it looking at position LookAt)

    hope that helps
    -ec-
  • : void gluLookAt(
    : GLdouble eyex, //
    : GLdouble eyey, //The position of the eye point.
    : GLdouble eyez, //
    : GLdouble centerx, //
    : GLdouble centery, //The reference point.
    : GLdouble centerz, //
    : GLdouble upx, //
    : GLdouble upy, //The direction of the up vector.
    : GLdouble upz //
    : );
    :
    : you might use it like this
    : gluLookAt(Player->position.x, Player->position.y,
    : Player->position.z,LookAt.x, LookAt.y, LookAt.z,0.0, 1.0, 0.0);
    : (Keeps the "camera" following the player and has it looking at position LookAt)
    :
    : hope that helps
    : -ec-
    :

    I found this tutorial on changing camera possitions http://www.liacs.nl/~dpalomo/camtut/camtut.html , followed it, but after I call gluLookAt, nothing happens, this is weird, because I know for a fact that the settings change ... anybody ?
  • I took a look at this tutorial, and I think you could try adding this line in Update_glMatrix implementation, before loadidentity :

    void camera::Update_glMatrix(){
    glMatrixMode(GL_PROJECTION);
    etc......

    but Im not sure. Try it and tell us what it gives.

    >I found this tutorial on changing camera positions >http://www.liacs.nl/~dpalomo/camtut/camtut.html , followed it, >but after I call gluLookAt, nothing happens, this is weird, >because I know for a fact that the settings change ... anybody ?


  • Well, the good news is that it does do something, the bad news is that I'm left with a blank screen ... for some reason nothing gets drawn anymore, even when I return to my original coordinates ... weird ...

    : I took a look at this tutorial, and I think you could try adding this line in Update_glMatrix implementation, before loadidentity :
    :
    : void camera::Update_glMatrix(){
    : glMatrixMode(GL_PROJECTION);
    : etc......
    :
    : but Im not sure. Try it and tell us what it gives.
    :
    : >I found this tutorial on changing camera positions >http://www.liacs.nl/~dpalomo/camtut/camtut.html , followed it, >but after I call gluLookAt, nothing happens, this is weird, >because I know for a fact that the settings change ... anybody ?
    :
    :
    :

  • Okay, I expected this. Now, try to go back into the modelview view matrix mode after the glulookat call doing this : in camera::update_glmatrix, add that line right after the gluLookAt call : glMatrixMode(GL_MODELVIEW);
    Try it out, one never knows...


    : Well, the good news is that it does do something, the bad news is that I'm left with a blank screen ... for some reason nothing gets drawn anymore, even when I return to my original coordinates ... weird ...
    :
    : : I took a look at this tutorial, and I think you could try adding this line in Update_glMatrix implementation, before loadidentity :
    : :
    : : void camera::Update_glMatrix(){
    : : glMatrixMode(GL_PROJECTION);
    : : etc......
    : :
    : : but Im not sure. Try it and tell us what it gives.


  • : Okay, I expected this. Now, try to go back into the modelview view matrix mode after the glulookat call doing this : in camera::update_glmatrix, add that line right after the gluLookAt call : glMatrixMode(GL_MODELVIEW);
    : Try it out, one never knows...
    :

    Nope, I still end up with a blank screen :-(
  • : : Okay, I expected this. Now, try to go back into the modelview view matrix mode after the glulookat call doing this : in camera::update_glmatrix, add that line right after the gluLookAt call : glMatrixMode(GL_MODELVIEW);
    : : Try it out, one never knows...
    : :
    :
    : Nope, I still end up with a blank screen :-(
    :

    Nevermind, I got it.
    I placed the camera::update_glmatrix method inside the rendering loop before the objects were drawn instead of automatically in an KeyPress event, and now it work (without glMatrixMode()).
    Thanks anyway :-)

  • : Nevermind, I got it.
    : I placed the camera::update_glmatrix method inside the rendering loop before the objects were drawn instead of automatically in an KeyPress event, and now it work (without glMatrixMode()).
    : Thanks anyway :-)
    :
    Are you sure there isn't any glMatrixMode(GL_PERSPECTIVE) in your whole code ? if yes I should misunderstand something.

  • : : Nevermind, I got it.
    : : I placed the camera::update_glmatrix method inside the rendering loop before the objects were drawn instead of automatically in an KeyPress event, and now it work (without glMatrixMode()).
    : : Thanks anyway :-)
    : :
    : Are you sure there isn't any glMatrixMode(GL_PERSPECTIVE) in your whole code ? if yes I should misunderstand something.
    :
    :

    Nope, I have a glMatrixMode(GL_DEPTH_TEST) in the Init part and glMatrixMode(GL_PROJECTION) and glMatrixMode(GL_MODELVIEW) in the ResizePart and those are the only glMatrixMode calls in all my code

  • : : : Nevermind, I got it.
    : : : I placed the camera::update_glmatrix method inside the rendering loop before the objects were drawn instead of automatically in an KeyPress event, and now it work (without glMatrixMode()).
    : : : Thanks anyway :-)
    : : :
    : : Are you sure there isn't any glMatrixMode(GL_PERSPECTIVE) in your whole code ? if yes I should misunderstand something.
    : :
    : :
    :
    : Nope, I have a glMatrixMode(GL_DEPTH_TEST) in the Init part and glMatrixMode(GL_PROJECTION) and glMatrixMode(GL_MODELVIEW) in the ResizePart and those are the only glMatrixMode calls in all my code
    :
    :
    the Init and ResizePart of my Window I mean offcourse, not the Camera :-)

  • : : Nope, I have a glMatrixMode(GL_DEPTH_TEST) in the Init part and glMatrixMode(GL_PROJECTION) and glMatrixMode(GL_MODELVIEW) in the ResizePart and those are the only glMatrixMode calls in all my code
    : :
    : :
    : the Init and ResizePart of my Window I mean offcourse, not the Camera :-)
    :

    Ok, so gluLookAt doesn't need the Perspective matrix to be active. It would have been cool that experienced people post some explanations, I'm just a very beginner in GL

  • Posting a reply to this message is not allowed, the reply chain can only be up to 10 posts deep. Try to post a new message or reply to a earlier message.

    ...
    doh


    anyway, I'm still pretty new at this too (I quit Graphics coding a little while to concentrate on my study, but then I got this itch to start again ;-)), anyway, I don't think there really are any OpenGL guru's on this board ... to bad, guess we're all stuck with each other ;-)
  • I had that same problem when i first used LookAt. Just watch where you place the line. Place the camera(LookAt) THEN the draw draw scene/world.
  • I know this is a very old post, but I search gluLookAt in google and this was on the front page so I couldn't let it have it's poor information.

    gluLookAt is NOT supposed to be called on the projection matrix. It is supposed to be called on the modelview matrix, that is why it is called the modelVIEW matrix.

    See article here [link=http://www.opengl.org/resources/faq/technical/projection_abuse.php]Projection Abuse[/link]

    As for order its always best to put the gluLookAt function right after the initial glLoadIdentity call so that it is the last applied. (Because matrix operations are performed in reverse order of their calls in OpenGL due to matrix multiplication)

    so in short your code should look like
    [code]glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    gluLookAt(eye.x, eye.y, eye.z, focus.x, focus.y, focus.z, 0, 1, 0);
    //Model Transformations[/code]

    Sorry for bringing up such an old post.
    Kasuko
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories