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