]> git.tdb.fi Git - libs/gl.git/blob - source/core/clipplane.cpp
Remove the misc.h header
[libs/gl.git] / source / core / clipplane.cpp
1 #include <msp/strings/format.h>
2 #include "clipplane.h"
3 #include "gl.h"
4 #include "matrix.h"
5 #include "programdata.h"
6
7 namespace Msp {
8 namespace GL {
9
10 ClipPlane::ClipPlane():
11         eq(0, 0, 0, 1),
12         generation(0)
13 { }
14
15 ClipPlane::ClipPlane(const Vector4 &e):
16         eq(e),
17         generation(0)
18 { }
19
20 ClipPlane::ClipPlane(const Vector3 &p, const Vector3 &d):
21         eq(compose(d, -dot(p, d))),
22         generation(0)
23 { }
24
25 void ClipPlane::set_equation(const Vector4 &e)
26 {
27         eq = e;
28         ++generation;
29 }
30
31 void ClipPlane::set_plane(const Vector3 &p, const Vector3 &d)
32 {
33         Vector3 nd = normalize(d);
34         set_equation(compose(nd, -dot(p, nd)));
35 }
36
37 void ClipPlane::update_shader_data(ProgramData &shdata, unsigned i) const
38 {
39         shdata.uniform(format("clip_planes[%d].equation", i), eq);
40 }
41
42 } // namespace GL
43 } // namespace Msp