--- /dev/null
+#include <msp/strings/format.h>
+#include "clipplane.h"
+#include "gl.h"
+#include "matrix.h"
+#include "misc.h"
+#include "programdata.h"
+
+namespace Msp {
+namespace GL {
+
+ClipPlane::ClipPlane():
+ eq(0, 0, 0, 1)
+{ }
+
+ClipPlane::ClipPlane(const Vector4 &e):
+ eq(e)
+{ }
+
+ClipPlane::ClipPlane(const Vector3 &p, const Vector3 &d):
+ eq(compose(d, -dot(p, d)))
+{ }
+
+void ClipPlane::set_equation(const Vector4 &e)
+{
+ eq = e;
+}
+
+void ClipPlane::set_plane(const Vector3 &p, const Vector3 &d)
+{
+ Vector3 nd = normalize(d);
+ set_equation(compose(nd, -dot(p, nd)));
+}
+
+void ClipPlane::update_shader_data(ProgramData &shdata, const Matrix &view_inverse, unsigned i) const
+{
+ shdata.uniform(format("clip_planes[%d].equation", i), eq*view_inverse);
+}
+
+} // namespace GL
+} // namespace Msp