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