PDA

View Full Version : gluPerspective Near and Far Plane



guju
07-07-2002, 12:26 AM
Hi!
I create my viewing volume with:
gluPerspective(angle, (GLfloat)w / (GLfloat)h, radius/100, 3*radius);
Then i wanted to create a quad at the near and at the far plane, which fill the whole plane. I thought that the width
and the height on the near plane are:
heigth=tan(angle)*radius/100*2
width=height*w/h
and for the far plane:
heigth=tan(angle)*radius*3*2
width=height*w/h

But these values does mot match ??
Thanks
Juergen

Bob
07-07-2002, 01:47 AM
Why not switch to an orthographic projection while drawing the quad? It's alot easier to get it to cover the entire screen that way.

guju
07-07-2002, 02:24 AM
Why is it easier?

Deiussum
07-07-2002, 09:08 AM
It's easier because for instance, you don't have to do any calculations to figure out the near clip plane. For instance if you used...

glOrtho(-1, 1, -1, 1, -1, 1);

You just draw your quad where one corner is at -1, -1, 0 and the other is at 1, 1, 0.

Anyway, your formulas seem off. If you have the following call...

gluPerspective(fov, aspect, near, far);

The formulas would be something like so..

maxY = tan(fov/2) * near;
minY = -maxY;
maxX = maxY * aspect;
minX = -maxX;

The far plane has the same formulas only you substitute far for near.



[This message has been edited by Deiussum (edited 07-07-2002).]