Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: glFrustum ?

  1. #1
    Junior Member Newbie
    Join Date
    Oct 2002
    Posts
    17

    glFrustum ?

    I'm wondering how glFrustum works.

    Let's say, I set a projection matrix using

    gluPerspective(60,(640/480),0.1,400)

    How would a call to glFrustum that creates
    the same projection matrix look like ?

    regards
    Ann

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    2,978

    Re: glFrustum ?

    Ok, I'l give it a try...

    n=near clipping plane
    f=far clipping plane
    a=aspect ratio

    l=-1*n*tan((a*fov)/2)
    r=far*tan((a*fov)/2)
    b=-1*n*tan(fov/2)
    t=far*tan(fov/2)

    glFrustum(l, r, b, t, n, f)

    Based on what I know (think it is), please say if it works or not. To get the matrix, just look on the web/in a book and see how to calculate each element with l, r, b, t, n and f.

    Also, be sure use radians when calling the standard C-function tan(), since you specify fov in gluPerspective in degrees.

    [This message has been edited by Bob (edited 05-31-2000).]

  3. #3
    Senior Member Frequent Contributor
    Join Date
    Feb 2000
    Posts
    569

    Re: glFrustum ?

    You have to first give you somekind of world proportion :

    Let's say that when something is 1 meters away from me, an object of 2 meters X 2 meters would fill all my view.

    This give those parameters :

    zNear = 1;
    top = 1; bottom = -1;
    left = -1; right = 1;

    Now everyone knows( ) that because of the way the z-buffer is done, having a zNear of 1 is not really good. So we will set zNear = 10.

    to keep our proportions :
    zNear = 10;
    left = -10; right =10
    top = 10
    bottom = -10

    That is just what there is to it!!! It's just simple proportions. You can even say :

    I am blind of the right eye! So the values are :

    zNear = 10;
    left = -10; right = 5; (5 for right because the two eyes field of view overlap)
    top = 10; bottom = -10;


    To tell you the truth, I really never understood why people don't understand the view frustum and can work with gluPerspective!!!! I mean, since when working with an angle is easier than with little "standard number" and proportions??

  4. #4
    Junior Member Newbie
    Join Date
    Oct 2002
    Posts
    17

    Re: glFrustum ?

    Gorg :
    It's because in many OpenGL books
    you can read :

    "Since glFrustum is soooo difficult to use, we will simply use gluPerspective etcblabla..."

    However, for some strange reason I don't feel like linking to glu.dll only because
    of one function.

    regards
    Ann

  5. #5
    Senior Member Frequent Contributor
    Join Date
    Feb 2000
    Location
    France
    Posts
    880

    Re: glFrustum ?

    Ann,

    Depending on the type of project you are working on, you might need another VERY useful function from the GLU library : the tesselators...

    You know, libraries have been done so that you do not have to reinvent the wheel each time you start a new program...

    Of course, you will find how to use glFrustum to obtain the same results than gluPerspective but is worth a waste of time ?

    Regards.

    Eric

    P.S. : nevertheless, I will be happy if you find a solution to your problem !

  6. #6
    Junior Member Newbie
    Join Date
    Oct 2002
    Posts
    17

    Re: glFrustum ?

    Eric :

    coding is a hobby of me. currently i'm working on an opengl 4k intro, and i'm happy
    for every library i can throw out, since
    this will create a (slightly) smaller exe.

    believe me, i know what i'm doing, i'm
    just new to opengl programming and i know
    also what libraries are good for

    if the result is a cool 4k intro, it's
    not a waste of time.

    regards
    Ann

  7. #7
    Senior Member Frequent Contributor
    Join Date
    Feb 2000
    Location
    France
    Posts
    880

    Re: glFrustum ?

    Got your point !

    Eric

    P.S. : it reminds me the good old days when I was coding demos on Atari ST/Falcon030 !

  8. #8
    Senior Member Frequent Contributor
    Join Date
    Feb 2000
    Posts
    569

    Re: glFrustum ?

    Ann, if you need more clarifications on glFrustum just ask.

  9. #9
    Junior Member Newbie
    Join Date
    Oct 2002
    Posts
    17

    Re: glFrustum ?

    Gorg : No, you explained very well how
    glFrustum works, thanx.

  10. #10
    Member Contributor
    Join Date
    May 2000
    Posts
    72

    Re: glFrustum ?

    I want to point out again that having a znear of 1 is not bad unless you have a large zfar. It's the ratio that matters. If you set the znear to 1 and zfar to 10, it's the same as setting znear to 10 and zfar to 100, but scaled. So set it to whatever you need to

Page 1 of 2 12 LastLast

Similar Threads

  1. glFrustum
    By Mukund in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 05-10-2010, 08:33 AM
  2. help about glFrustum
    By in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 09-16-2005, 10:32 PM
  3. glFrustum
    By imported_Flavius in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 04-18-2001, 03:55 AM
  4. glFrustum()...
    By jtwoods in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 12-20-2000, 01:08 PM
  5. glFrustum
    By in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 12-04-2000, 02:44 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