PDA

View Full Version : glFrustum/glOrtho



jenny
08-14-2002, 02:58 PM
Could someone explain glFrustum and glOrtho to me? I just really don't understand what the arguments are supposed to be.

In the red book, they use glFrustrum (-1.0 1.0 -1.0 1.0 1.5 20.0) in an example. why are there negitives? Shouldn't left and right both be just the height of my screen? and top and bottom both be the width of my screen?

--confused.

owcs
08-14-2002, 04:49 PM
void glFrustum(GLdouble left,
GLdouble right,
GLdouble bottom,
GLdouble top,
GLdouble near,
GLdouble far)

by specifying the left, bottom to -1 and right, top to 1, what you are basically doing is making the origin to be at the center of the screen. and no, the parameters need not be the height and width of your screen. it's up to you. these parameters just sets up the 'world' coordinate. (disclaimer: i am not a pro at this so my explanation might be slightly off)


Originally posted by jenny:
Could someone explain glFrustum and glOrtho to me? I just really don't understand what the arguments are supposed to be.

In the red book, they use glFrustrum (-1.0 1.0 -1.0 1.0 1.5 20.0) in an example. why are there negitives? Shouldn't left and right both be just the height of my screen? and top and bottom both be the width of my screen?

--confused.

Deiussum
08-15-2002, 05:34 AM
Both glFrustum and glOrtho define the shape of your viewing volume. That is... the shape of the area where things will be visible.

glOrtho basically defines a viewing volume that is a box, and therefore has no perspective. (e.g. things don't get smaller as they get further away)

glFrustum defines a viewing volume that is the shape of a 4 sided pyramid with the top chopped off. The near plane being the top. The first four parameters basically establish the width and height of the near clip plane. The fifth parameter defines the distance from your "eye" that the near plane is at.

What's important to understand is that by adjusting these first 5 parameters basically defines your field of view. Assuming you keep the size of the first four the same, as you move the near clip plane closer, you increase the FOV, and as you move it further away it decreases. Think of the eye point as being the top of the pyramid. Now think of the shape of the pyramid as you move the base further from the top, and you should see why this is.

The far clip plane is defined by the last parameter of glFrustum. That basically defines the furthest distance you can see things. Adjusting that won't affect your FOV at all, just the depth to which you can see. You don't generally want to set this too drastically far out, you have a better chance of experiencing z fighting in the depth buffer. The greater the distance between the near and far clip planes, the more values you need in between in order to keep track of the depth of draw objects.



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

n123456
08-15-2002, 07:33 AM
they use cartesian coordinates

all axis "0"s are in the middle let's say

-X is to the left
+X is to the right

-Y is to the bottom
+Y is to the top

-Z is far "or into the screen"
+Z is near "or coming out of the screen"

draw a circle
then draw a line from top to bottom
label the top of the line +Y
lable the bottom of the line -Y
then draw a line from left to righ
label the left of the line -X
label the right of the line +X