-/* $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
-{
- glUniform1iARB(index, v);
-}
-
-Uniform1i *Uniform1i::clone() const
-{
- return new Uniform1i(v);
-}
-
-
-Uniform1f::Uniform1f(float v_):
- v(v_)
-{ }
-
-void Uniform1f::apply(int index) const
+template<>
+void UniformScalar<int>::apply(int index, unsigned size, const int *value)
{
- glUniform1fARB(index, v);
+ glUniform1ivARB(index, size, value);
}
-Uniform1f *Uniform1f::clone() const
+template<>
+void UniformScalar<float>::apply(int index, unsigned size, const float *value)
{
- return new Uniform1f(v);
+ glUniform1fvARB(index, size, value);
}
-Uniform2f::Uniform2f(float v0, float v1)
+template<>
+void UniformVector<float, 2>::apply(int index, unsigned size, const float *value)
{
- v[0] = v0;
- v[1] = v1;
+ glUniform2fvARB(index, size, value);
}
-void Uniform2f::apply(int index) const
+template<>
+void UniformVector<float, 3>::apply(int index, unsigned size, const float *value)
{
- glUniform2fvARB(index, 1, v);
+ glUniform3fvARB(index, size, value);
}
-Uniform2f *Uniform2f::clone() const
+template<>
+void UniformVector<float, 4>::apply(int index, unsigned size, const float *value)
{
- return new Uniform2f(v[0], v[1]);
+ glUniform4fvARB(index, size, value);
}
-Uniform3f::Uniform3f(float v0, float v1, float v2)
-{
- v[0] = v0;
- v[1] = v1;
- v[2] = v2;
-}
-
-void Uniform3f::apply(int index) const
-{
- glUniform3fvARB(index, 1, v);
-}
-
-Uniform3f *Uniform3f::clone() const
-{
- return new Uniform3f(v[0], v[1], v[2]);
-}
-
-
-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
-{
- glUniform4fvARB(index, 1, v);
-}
-
-Uniform4f *Uniform4f::clone() const
+template<>
+void UniformMatrix<float, 4, 4>::apply(int index, unsigned size, const float *value)
{
- return new Uniform4f(v[0], v[1], v[2], v[3]);
+ glUniformMatrix4fvARB(index, size, false, value);
}
} // namespace GL