]> git.tdb.fi Git - libs/gl.git/blobdiff - source/uniform.cpp
Rewrite the Uniform classes as templates
[libs/gl.git] / source / uniform.cpp
index 88c42d377067f73fbde380164b7acad458b6cdf7..688052ff16d0ae3b8fdebc5fafe99e1025c118d9 100644 (file)
@@ -1,72 +1,45 @@
-/* $Id$
-
-This file is part of libmspgl
-Copyright © 2007  Mikko Rasa, Mikkosoft Productions
-Distributed under the LGPL
-*/
-
 #include "arb_shader_objects.h"
 #include "uniform.h"
 
 namespace Msp {
 namespace GL {
 
-Uniform1i::Uniform1i(int v_):
-       v(v_)
-{ }
-
-void Uniform1i::apply(int index) const
+template<>
+void UniformScalar<int>::apply(int index) const
 {
-       glUniform1iARB(index, v);
+       glUniform1iARB(index, value);
 }
 
-
-Uniform1f::Uniform1f(float v_):
-       v(v_)
-{ }
-
-void Uniform1f::apply(int index) const
+template<>
+void UniformScalar<float>::apply(int index) const
 {
-       glUniform1fARB(index, v);
+       glUniform1fARB(index, value);
 }
 
 
-Uniform2f::Uniform2f(float v0, float v1)
-{
-       v[0]=v0;
-       v[1]=v1;
-}
-
-void Uniform2f::apply(int index) const
+template<>
+void UniformVector<float, 2>::apply(int index) const
 {
-       glUniform2fvARB(index, 1, v);
+       glUniform2fvARB(index, 1, value);
 }
 
-
-Uniform3f::Uniform3f(float v0, float v1, float v2)
+template<>
+void UniformVector<float, 3>::apply(int index) const
 {
-       v[0]=v0;
-       v[1]=v1;
-       v[2]=v2;
+       glUniform3fvARB(index, 1, value);
 }
 
-void Uniform3f::apply(int index) const
+template<>
+void UniformVector<float, 4>::apply(int index) const
 {
-       glUniform3fvARB(index, 1, v);
+       glUniform4fvARB(index, 1, value);
 }
 
 
-Uniform4f::Uniform4f(float v0, float v1, float v2, float v3)
-{
-       v[0]=v0;
-       v[1]=v1;
-       v[2]=v2;
-       v[3]=v3;
-}
-
-void Uniform4f::apply(int index) const
+template<>
+void UniformMatrix<float, 4, 4>::apply(int index) const
 {
-       glUniform4fvARB(index, 1, v);
+       glUniformMatrix4fvARB(index, 1, false, value);
 }
 
 } // namespace GL