Question

I understand the concept behind a frustrum viewing system; it's shaped like a pyramid, and as objects get closer to the center, they get smaller until they're finally clipped off. However, when using a viewing projecting in say, OpenGL (heads up: I don't use deprecated features), you set up your coordinate system like so:

orthoExample(left, right, bottom, top, near, far);

That's all fine, but when it comes to say, perspective, things get a bit strange.

perspectiveExample(field_of_view_y, aspect, near, far);

How do I go about setting up a coordinate system with a function like this?!? It doesn't let me specify a left, right, bottom, top, etc. I know perspective is just a variation of a frustrum projection...

Was it helpful?

Solution

The code found here should clear things up for you.

The Z-axis is taken to be the center of projection. tan(fov_y)*near gives you top (and the negative, bottom). aspect is the ratio of width to height, so multiplying top by aspect gives you right and the negative of that is left.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top