Visualizing Frustum

I have a simple frustum defined by six planes:

  
float md_arrFrustumPlanes[6][4];

If any one has a code snip for visualizing a frusum I would be very happy.

The best way to visualize a frustum is to transform a unit cube with the inverse projection matrix.

Well that is less flexible than what I aim for. This way you can only render the entire view frustum or nothing. I as said to render the invidual planes.

Then just render a single side of the unit cube, transformed by the inverse projection matrix :wink:

The other possibility is to intersect 3 planes to generate a vertex. For example, when you want to visualize the near plane, intersect the near plane with the top, left, bottom and right planes (pairwise) to generate the 4 vertices.

If you do the math, you’ll get a system of linear equations. Each plane is actually a linear equation in 3 variables, so with 3 planes you have 3 equations in 3 variables per vertex. That has to be done for every combination of 3 planes (that are not opposite), giving 8 vertices.