I tried to clip mesh in openGl and i think that i have a problem with math.
I have a cube 
And i need to clip for example half of that cube. So i didn't understand how to calculate this clipping plane. White lines illustrate how this clip plane should looks like, it is just parallel one of the cube sides
My clipping
#version 120
varying vec3 ourColor;
varying float clip_distance;
void main()
{
if ( clip_distance < 0.0 )
discard;
gl_FragColor = vec4(ourColor, 1.0);
}
#version 120
attribute vec3 aPos;
attribute vec3 aColor;
varying vec3 ourColor;
uniform mat4 model;
uniform mat4 view;
uniform mat4 projection;
varying float clip_distance;
const vec4 clipPlane = vec4(1.0, 1.0, 1.0, -1.0);
void main()
{
gl_Position = projection * view * model * vec4(aPos, 1.0);
clip_distance = dot(gl_Position, clipPlane);
ourColor = aColor;
}
So, how to calculate this clipping plane. I want to understand how to calculate clipping planes for each of cube sides