]> git.tdb.fi Git - libs/gl.git/blobdiff - source/uniform.cpp
Bind ProgramData to a Program upon construction
[libs/gl.git] / source / uniform.cpp
index 8ed1336e4d05268ded65f707ddd0f64f3baad3b7..37868e794cb762200d7706f3c46ad74207bfd07b 100644 (file)
@@ -1,10 +1,11 @@
 /* $Id$
 
 This file is part of libmspgl
-Copyright © 2007  Mikko Rasa, Mikkosoft Productions
+Copyright © 2007, 2010-2011  Mikko Rasa, Mikkosoft Productions
 Distributed under the LGPL
 */
 
+#include <algorithm>
 #include "arb_shader_objects.h"
 #include "uniform.h"
 
@@ -43,8 +44,8 @@ Uniform1f *Uniform1f::clone() const
 
 Uniform2f::Uniform2f(float v0, float v1)
 {
-       v[0]=v0;
-       v[1]=v1;
+       v[0] = v0;
+       v[1] = v1;
 }
 
 void Uniform2f::apply(int index) const
@@ -60,9 +61,9 @@ Uniform2f *Uniform2f::clone() const
 
 Uniform3f::Uniform3f(float v0, float v1, float v2)
 {
-       v[0]=v0;
-       v[1]=v1;
-       v[2]=v2;
+       v[0] = v0;
+       v[1] = v1;
+       v[2] = v2;
 }
 
 void Uniform3f::apply(int index) const
@@ -78,10 +79,10 @@ Uniform3f *Uniform3f::clone() const
 
 Uniform4f::Uniform4f(float v0, float v1, float v2, float v3)
 {
-       v[0]=v0;
-       v[1]=v1;
-       v[2]=v2;
-       v[3]=v3;
+       v[0] = v0;
+       v[1] = v1;
+       v[2] = v2;
+       v[3] = v3;
 }
 
 void Uniform4f::apply(int index) const
@@ -94,5 +95,21 @@ Uniform4f *Uniform4f::clone() const
        return new Uniform4f(v[0], v[1], v[2], v[3]);
 }
 
+
+UniformMatrix4x4f::UniformMatrix4x4f(const float *vp)
+{
+       std::copy(vp, vp+16, v);
+}
+
+void UniformMatrix4x4f::apply(int index) const
+{
+       glUniformMatrix4fvARB(index, 1, false, v);
+}
+
+UniformMatrix4x4f *UniformMatrix4x4f::clone() const
+{
+       return new UniformMatrix4x4f(v);
+}
+
 } // namespace GL
 } // namespace Msp