X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Funiform.cpp;h=b183719fe339debaf55402b35cb2eeda15bb3d8a;hp=8ed1336e4d05268ded65f707ddd0f64f3baad3b7;hb=49f1812b3e5ad73748015df52d0e4dee17246036;hpb=97015ec7bddd26aa746f5227e4109b7d32438cca diff --git a/source/uniform.cpp b/source/uniform.cpp index 8ed1336e..b183719f 100644 --- a/source/uniform.cpp +++ b/source/uniform.cpp @@ -1,97 +1,75 @@ -/* $Id$ - -This file is part of libmspgl -Copyright © 2007 Mikko Rasa, Mikkosoft Productions -Distributed under the LGPL -*/ - -#include "arb_shader_objects.h" +#include #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 +template<> +void UniformScalar::apply(int index, unsigned size, const int *value) { - return new Uniform1i(v); + glUniform1iv(index, size, value); } - -Uniform1f::Uniform1f(float v_): - v(v_) -{ } - -void Uniform1f::apply(int index) const -{ - glUniform1fARB(index, v); -} - -Uniform1f *Uniform1f::clone() const +template<> +void UniformScalar::apply(int index, unsigned size, const float *value) { - return new Uniform1f(v); + glUniform1fv(index, size, value); } -Uniform2f::Uniform2f(float v0, float v1) +template<> +void UniformVector::apply(int index, unsigned size, const int *value) { - v[0]=v0; - v[1]=v1; + glUniform2iv(index, size, value); } -void Uniform2f::apply(int index) const +template<> +void UniformVector::apply(int index, unsigned size, const float *value) { - glUniform2fvARB(index, 1, v); + glUniform2fv(index, size, value); } -Uniform2f *Uniform2f::clone() const +template<> +void UniformVector::apply(int index, unsigned size, const int *value) { - return new Uniform2f(v[0], v[1]); + glUniform3iv(index, size, value); } - -Uniform3f::Uniform3f(float v0, float v1, float v2) +template<> +void UniformVector::apply(int index, unsigned size, const float *value) { - v[0]=v0; - v[1]=v1; - v[2]=v2; + glUniform3fv(index, size, value); } -void Uniform3f::apply(int index) const +template<> +void UniformVector::apply(int index, unsigned size, const int *value) { - glUniform3fvARB(index, 1, v); + glUniform4iv(index, size, value); } -Uniform3f *Uniform3f::clone() const +template<> +void UniformVector::apply(int index, unsigned size, const float *value) { - return new Uniform3f(v[0], v[1], v[2]); + glUniform4fv(index, size, value); } -Uniform4f::Uniform4f(float v0, float v1, float v2, float v3) +template<> +void UniformMatrix::apply(int index, unsigned size, const float *value) { - v[0]=v0; - v[1]=v1; - v[2]=v2; - v[3]=v3; + glUniformMatrix2fv(index, size, false, value); } -void Uniform4f::apply(int index) const +template<> +void UniformMatrix::apply(int index, unsigned size, const float *value) { - glUniform4fvARB(index, 1, v); + glUniformMatrix3fv(index, size, false, value); } -Uniform4f *Uniform4f::clone() const +template<> +void UniformMatrix::apply(int index, unsigned size, const float *value) { - return new Uniform4f(v[0], v[1], v[2], v[3]); + glUniformMatrix4fv(index, size, false, value); } } // namespace GL