# Clipping planes

I’d like to add some rough view-frustum clipping to my terrain renderer. The problem is: how can I get the 6 standard clipping planes coefficients?
I have two ideas:
first, calculate them as if I were in the origin lookin down the z-axis (default), then use the current modelview matrix to transform them correctly.
Second: I don’t know, maybe there’s a way to ask OpenGl about them, or another way to do frustum clipping.

why don’t use frustum bounding sphere instead of frustum planes?

maybe is better, since with a single test you can see if polygon or object is near the frustum…

Dolo//\ightY

Use glFrustum. Specs for example at http://www.eecs.tulane.edu/www/graphics/doc/OpenGL-Man-Pages/opengl_index_alpha.html

I mean I’d like to clip objects before sending them to the rendering queue. I could consider the idea of using spheres, but I still need to take into account the planes that define the view frustum.

Ohh… Then you have to make your own frustum calculations. I guess you can’t directly access the OpenGL clipping planes.

fovy = vertical fov
aspect = aspect ratio (width/height)
nearz = distance from near clipping plane
farz = distance from far clipping plane

sy = sin(fovy0.5)
cy = cos(fovy
0.5)
sx = aspectsy
cx = aspect
cy

plane[0] = (sx, 0, cx, 0)
plane[1] = (-sx, 0, cx, 0)
plane[2] = (0, -sy, cy, 0)
plane[3] = (0, sy, cy, 0)
plane[4] = (0, 0, 1, znear)
plane[5] = (0, 0, -1, zfar)

This is the frustum in view space. If you want to do clipping in object space, you need to transform the frustum into object space first.
For this you need to transform the plane normals into object space. You also need some points on the planes, so transform eye point (0, 0, 0), near point (0, 0, znear) and far point (0, 0, zfar) into object space. Then calculate the plane equations.
So, you need to implement all this matrix stuff etc. yourself.