Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: confused about gluLookAt

  1. #1
    Junior Member Regular Contributor
    Join Date
    Mar 2003
    Location
    Chicago, IL US
    Posts
    100

    confused about gluLookAt

    Hello,

    I am trying to use gluLookAt with perspective projection to "view" a 2d array of square polygons of different colors that I have drawn. The problem is I can only see a few of these. I believe that I need to adjust the first 3 args to gluLookAt but am not sure if I need to adjust the others as well. I currently have:

    gluLookAt(0, 0, 350, 0, 0, 0, 0, 1, 0);

    in my display function.

    I read thru:
    http://www.opengl.org/developers/gaq...al/viewing.htm

    but am still confused about this.

    Any suggestions are appreciated.

    Thanks.

  2. #2
    Junior Member Newbie
    Join Date
    Oct 2002
    Location
    Los Angeles, Ca, USA
    Posts
    22

    Re: confused about gluLookAt

    Increasing viewangle will help,
    heres some more complete camera code
    that may help


    float eyex, eyey, eyez; // eye
    float near, far; // near and far clipping distance
    float viewangle; // vertical view angle in degrees
    float twist; // rotation angle about the view axis

    int width, height; // input canvas width and height

    // temp variables
    float upx, upy, upz;
    float aspect;
    float rx, ry, rz;

    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    aspect = (float)width/(float)height;
    gluPerspective(viewangle, aspect, near, far);
    rx = coix - eyex;
    ry = coiy - eyey;
    rz = coiz - eyez;
    if (rx != 0.0 | | rz != 0.0) {
    upx = 0.0; upy = 1.0; upz = 0.0;
    }
    else {
    upx = 0.0; upy = 0.0; upz = -1.0;
    }
    gluLookAt(eyex, eyey, eyez, coix, coiy, coiz, upx, upy, upz);
    glRotatef(twist, rx, ry, rz);

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •