View Full Version : How do I read the view frustum parameters?

rangers99

02-21-2002, 08:42 PM

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.opengl.org/discussion_boards/ubb/wink.gif

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).]

Sundy

02-22-2002, 07:48 AM

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).]

rangers99

02-22-2002, 04:56 PM

brilliant.

Many thanks guys.

rangers99

02-25-2002, 01:59 AM

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

richardve

02-25-2002, 03:41 AM

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 (http://www.flipcode.com/documents/matrfaq.html)

rangers99

02-25-2002, 04:08 AM

Excellent link thanks.

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.

Tom Nuydens

02-25-2002, 04:25 AM

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

rangers99

02-25-2002, 04:22 PM

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(..))

rangers99

03-04-2002, 09:00 PM

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).

zeckensack

03-04-2002, 11:25 PM

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 http://www.opengl.org/discussion_boards/ubb/smile.gif

Powered by vBulletin® Version 4.2.5 Copyright © 2018 vBulletin Solutions Inc. All rights reserved.