gluLookAt - Programmers Heaven

Howdy, Stranger!

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

Categories

gluLookAt

chris666chris666 Posts: 71Member
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
«1

Comments

  • DrGonzoDrGonzo Posts: 41Member
    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-
  • iDaZeiDaZe Posts: 464Member
    : 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 ?
  • chris666chris666 Posts: 71Member
    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 ?


  • iDaZeiDaZe Posts: 464Member
    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 ?
    :
    :
    :

  • chris666chris666 Posts: 71Member
    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.


  • iDaZeiDaZe Posts: 464Member
    : 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 :-(
  • iDaZeiDaZe Posts: 464Member
    : : 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 :-)

  • chris666chris666 Posts: 71Member
    : 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.

  • iDaZeiDaZe Posts: 464Member
    : : 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

  • iDaZeiDaZe Posts: 464Member
    : : : 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 :-)

«1
Sign In or Register to comment.