# How do I read the view frustum parameters?

Hi

I know how to SET the frustum parameters using glfrustum but how do I READ them?

I want to know the current size, position and, distance from the viewpoint, of the image (near?) plane.

cheers

Hi

The easy way, copy what someone else did

http://www.markmorley.com/opengl/frustumculling.html

Above is a very good tutorial on Frustum culling, part of this is extracting the Frustum planes. I hope this is what you were looking for.

3DG

[This message has been edited by 3DG (edited 02-22-2002).]

use glGet(GL_PROJECTION_MATRIX,…)
The Projection Matrix has all the information you need, to get the individual parameters, you need to find some way of solving this matrix. glFrustum() documentation has information on these values and how the matrix was constructed.

-Sundar

[This message has been edited by Sundy (edited 02-22-2002).]

brilliant.

Many thanks guys.

Hi again.

Im still trying to get the size and position of the near plane. Also the distance to the far plane.

The code example shows how to get equations for all 6 viewing frustum planes. I guess by working out intersections etc , i can get the information I need. However this is not so simple.

The documentation for glget(GL_PROJECTION_MATRIX) in MSDN at least is well nigh useless because it doesn’t describe what the 16 values represent.

Surely there must be an easy way to read the viewing frustum data.

Or can anyone tell me the default values for the viewing frustum?

cheers

The documentation for glget(GL_PROJECTION_MATRIX) in MSDN at least is well nigh useless because it doesn’t describe what the 16 values represent.

I’d recommend you to learn something about matrices first (and trigonometry would also be nice) before diving into this stuff because you won’t get far when you don’t even know what those 16 values represent…

(no offense, but it’ll be a lot easier when you know the basics)

Hint: Matrix FAQ

However I do understand matrices quite well.

Perhaps Im expecting too much from OPenGL but why should it be so much trouble to find some basic information about the viewing volume?

Ive even spent the last couple of hours search for “opengl default viewing paramters” (or similar) and I STILL dont know the default parameters!

Anyway Ill keep trying. Im new to this OPenGL programming caper.

Originally posted by rangers99:
Or can anyone tell me the default values for the viewing frustum?

All matrices (MODELVIEW, PROJECTION, TEXTURE) default to the identity matrix. For the projection, this is equivalent to a frustum that is a unit cube centered on the origin.

If you’re ever in doubt about what the default state for something is, the OpenGL specification is the only place you need to look.

– Tom

cheers mate.

check the red book (appendix) for info on how the projection matrix is calculated (u can easily write your own then + call it with glLoadMatrix(…))

Tom

You said:

“All matrices (MODELVIEW, PROJECTION, TEXTURE) default to the identity matrix. For the projection, this is equivalent to a frustum that is a unit cube centered on the origin.”

This doesn’t make sense to me. The default viewpoint is (0,0,0) so that makes the default viewpoint inside the default frustum. I thought the viewpoint was at the apex of a pyramid and the viewing volume is a truncated pyramid, truncated by the near-plane (image-plane).

The default viewing volume is a cube. This is an orthographic projection (ie screen size of objects doesn’t change with distance). If you get a grip on the involved math, you’ll see that it’s actually quite easy to ‘deactivate’ perspective division. The spec is your best friend