Results 1 to 2 of 2

Thread: glLookAt problem

  1. #1
    Junior Member Newbie
    Join Date
    Dec 2012

    Exclamation glLookAt problem

    Hi Everybody, I have a small problem.

    I am using gluLookAt in with keyboard char 'f' so when i press the 'f' key the camera zooms towards the object its meant to zoom until it can go no more, when it reaches the end the camera returns to its original position.

    My problem is I have previously done this code and it worked fine, I had it commented out for a while until I completed everything else and for some reason now its not working at all.

    Here is my relevant code:

    gluPerspective(45.0f, fAspect, 1.0, 600.0);

    GLfloat eyePosition = 500.0;//default position

    void normalKeys(unsigned char key, int x, int y)
    if (key == 'f')
    eyePosition = eyePosition - 100.0;

    void RenderScene(void)

    glMatrixMode (GL_MODELVIEW);

    glTranslatef(0.0f, 0.0f, -100.0f);


    glFlush(); //execute drawing commands in buffer


  2. #2
    Senior Member OpenGL Pro Aleksandar's Avatar
    Join Date
    Jul 2009
    Move glLoadIdentity at the position of glPushMatrix. glPushMatrix can be removed since it probably does nothing, as well as glFlush. gluLookAt shoud be the first command after glLoadIdentity, since it is a complete view transformation. glTranslate can be incorporated into gluLookAt. Please read third chapter of some of the previous releases of OpenGL Programming Guide.

Similar Threads

  1. glLookat, you see what?
    By reader1 in forum OpenGL: Basic Coding
    Replies: 14
    Last Post: 04-29-2015, 08:20 PM
  2. glLookat
    By joker40 in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 04-11-2011, 08:44 PM
  3. gluLookat or glLookat?
    By in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 03-01-2004, 11:16 PM
  4. Fog + glLookAt() ??
    By in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 03-23-2001, 06:57 PM
  5. about glLookAt
    By lxb in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 11-27-2000, 06:52 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Proudly hosted by Digital Ocean