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 4 of 4

Thread: gluPerspective and glFrustum

  1. #1
    Guest

    gluPerspective and glFrustum

    Hi.
    Im new to 3D programming/math and i can't really understand gluPerspective
    I mean how do I know based on the parameters
    what the coordinates at the far right, left, top, bottom will be it seems like I have no control, I tried to use glFrustum instead but when I created an object at the specified far right it ended up halfway there

    i know this must sound stupid but i got no clue on how this works

    thanks in advance

  2. #2
    Intern Contributor
    Join Date
    Oct 2001
    Location
    Orange County, Ca
    Posts
    62

    Re: gluPerspective and glFrustum

    hehe, don't worry I know exactly what you are going thru.

    First and foremost I recommend getting the OpenGL Programming Guide. Its very easy to learn from and covers the different viewing volumns. Plus it tells you how to calculate the matrices for these volumns in the appendices.

    In the mean time, gluPerspective and glFrustum create a parallelpiped viewing volumn. Just in case you dont remember what that is think of a pyramid with the top cut off. The near plane is the top of the modified pyramid and the far plane is the bottom, and the camera would be at where the top of the original pyramid was, looking down.

    Code :
        camera
         / \
       near plane
       /     \
      /       \
      far plane
    As your object gets farther away it becomes smaller and the width of your view volume increases. So if your near plane is x = -1 to +1, z = +1 and you draw a object at x = +1 z = +1 it will appear on the right side of the screen but as you move it close to the far plane it will not be on the right side of the screen anymore since the volume has increased in the x direction.

    I hope that makes sense, sorry if I consfuse you more.

    KC

  3. #3
    Guest

    Re: gluPerspective and glFrustum

    Thanks for the help.
    I have now read some on glFurstum and gluPerspective but im still missing something

    im calculating the Furstum like gluPerspective does:

    ymax = zNear * tan(fovy)
    ymin = -ymax
    xmin = ymin * aspect
    xmax = ymax * aspect

    now lets say:
    fovy = 45
    aspect = 4/3
    zNear = 1
    then i get:
    glFrustum(-1.3, 1.3, -1, 1, 1, 100)

    now when i check to see if an object has an X value greater then 1.3 and if so place it at 1.3 it still just get stuck somwhere on the way to the far right of the screen

    what is it im missing here??

    thanks in advance

  4. #4
    Junior Member Regular Contributor
    Join Date
    Dec 2001
    Location
    Belmont, CA, USA
    Posts
    224

    Re: gluPerspective and glFrustum

    You don't say what the Z value is and that affects where it shows up on the screen.

Posting Permissions

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