]> git.tdb.fi Git - libs/gl.git/blob - source/uniform.cpp
Drop Id tags and copyright notices from files
[libs/gl.git] / source / uniform.cpp
1 #include <algorithm>
2 #include "arb_shader_objects.h"
3 #include "uniform.h"
4
5 namespace Msp {
6 namespace GL {
7
8 Uniform1i::Uniform1i(int v_):
9         v(v_)
10 { }
11
12 void Uniform1i::apply(int index) const
13 {
14         glUniform1iARB(index, v);
15 }
16
17 Uniform1i *Uniform1i::clone() const
18 {
19         return new Uniform1i(v);
20 }
21
22
23 Uniform1f::Uniform1f(float v_):
24         v(v_)
25 { }
26
27 void Uniform1f::apply(int index) const
28 {
29         glUniform1fARB(index, v);
30 }
31
32 Uniform1f *Uniform1f::clone() const
33 {
34         return new Uniform1f(v);
35 }
36
37
38 Uniform2f::Uniform2f(float v0, float v1)
39 {
40         v[0] = v0;
41         v[1] = v1;
42 }
43
44 void Uniform2f::apply(int index) const
45 {
46         glUniform2fvARB(index, 1, v);
47 }
48
49 Uniform2f *Uniform2f::clone() const
50 {
51         return new Uniform2f(v[0], v[1]);
52 }
53
54
55 Uniform3f::Uniform3f(float v0, float v1, float v2)
56 {
57         v[0] = v0;
58         v[1] = v1;
59         v[2] = v2;
60 }
61
62 void Uniform3f::apply(int index) const
63 {
64         glUniform3fvARB(index, 1, v);
65 }
66
67 Uniform3f *Uniform3f::clone() const
68 {
69         return new Uniform3f(v[0], v[1], v[2]);
70 }
71
72
73 Uniform4f::Uniform4f(float v0, float v1, float v2, float v3)
74 {
75         v[0] = v0;
76         v[1] = v1;
77         v[2] = v2;
78         v[3] = v3;
79 }
80
81 void Uniform4f::apply(int index) const
82 {
83         glUniform4fvARB(index, 1, v);
84 }
85
86 Uniform4f *Uniform4f::clone() const
87 {
88         return new Uniform4f(v[0], v[1], v[2], v[3]);
89 }
90
91
92 UniformMatrix4x4f::UniformMatrix4x4f(const float *vp)
93 {
94         std::copy(vp, vp+16, v);
95 }
96
97 void UniformMatrix4x4f::apply(int index) const
98 {
99         glUniformMatrix4fvARB(index, 1, false, v);
100 }
101
102 UniformMatrix4x4f *UniformMatrix4x4f::clone() const
103 {
104         return new UniformMatrix4x4f(v);
105 }
106
107 } // namespace GL
108 } // namespace Msp