1. 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. 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. 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. Re: glFrustum ?

Gorg :
It's because in many OpenGL books

"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. 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. 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. Re: glFrustum ?

Eric

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

8. Re: glFrustum ?

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

9. Re: glFrustum ?

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

10. 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 Last

Posting Permissions

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