Search for clipplane in the GLSL Spec and you’ll come right to the two references.
In short, google for gl_ClipPlane GLSL for code snippets and tips.
Haven’t used it so can’t give you specifics, but the code fragments google flipped up made it look like it just contains the plane equation coefficients.
Sorry for asking, but what happens if the clip test fails? You can’t clip a vertex, you can only clip a primitive. If the vertex if discarded, one would surely get strange results.
I just want to know what’s wrong with my code and how can I fix it. my question is clear.
Edit: It seems that with my code, nothing happens and clip planes don’t work.
I found the answer!
simply adding this code to vertex shader sloves the problem:
gl_Position = ftransform();
// fix of the clipping bug for both Nvidia and ATi
#ifdef __GLSL_CG_DATA_TYPES
gl_ClipVertex = gl_ModelViewMatrix * gl_Vertex;
#endif
We then enable and specifly our clipping planes via the OpenGL API and this code snippet does clipping for us!