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