From: Mikko Rasa Date: Mon, 3 Sep 2012 10:18:30 +0000 (+0300) Subject: Add 3x3 and 2x2 uniform matrices X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=commitdiff_plain;h=8f7d5b6460ef68e7316c7f556b7152d9c9f7bfe2 Add 3x3 and 2x2 uniform matrices --- diff --git a/source/programdata.cpp b/source/programdata.cpp index ed4b0a29..1ecd3a1d 100644 --- a/source/programdata.cpp +++ b/source/programdata.cpp @@ -119,6 +119,16 @@ void ProgramData::uniform4(const string &name, const float *v) uniform(name, new Uniform4f(v)); } +void ProgramData::uniform_matrix2(const string &name, const float *v) +{ + uniform(name, new UniformMatrix2x2f(v)); +} + +void ProgramData::uniform_matrix3(const string &name, const float *v) +{ + uniform(name, new UniformMatrix3x3f(v)); +} + void ProgramData::uniform_matrix4(const string &name, const float *v) { uniform(name, new UniformMatrix4x4f(v)); diff --git a/source/programdata.h b/source/programdata.h index 38803c57..3cef2d4c 100644 --- a/source/programdata.h +++ b/source/programdata.h @@ -87,6 +87,8 @@ public: void uniform(const std::string &, const Vector4 &); void uniform(const std::string &, const Color &); void uniform4(const std::string &, const float *); + void uniform_matrix2(const std::string &, const float *); + void uniform_matrix3(const std::string &, const float *); void uniform_matrix4(const std::string &, const float *); void uniform_matrix4(const std::string &, const Matrix &); void uniform1_array(const std::string &, unsigned, const float *); diff --git a/source/uniform.cpp b/source/uniform.cpp index 09450a9a..8aba365b 100644 --- a/source/uniform.cpp +++ b/source/uniform.cpp @@ -36,6 +36,18 @@ void UniformVector::apply(int index, unsigned size, const float *value } +template<> +void UniformMatrix::apply(int index, unsigned size, const float *value) +{ + glUniformMatrix2fv(index, size, false, value); +} + +template<> +void UniformMatrix::apply(int index, unsigned size, const float *value) +{ + glUniformMatrix2fv(index, size, false, value); +} + template<> void UniformMatrix::apply(int index, unsigned size, const float *value) { diff --git a/source/uniform.h b/source/uniform.h index f8a59f2a..156fe676 100644 --- a/source/uniform.h +++ b/source/uniform.h @@ -121,6 +121,8 @@ public: { return new UniformMatrix(value); } }; +typedef UniformMatrix UniformMatrix2x2f; +typedef UniformMatrix UniformMatrix3x3f; typedef UniformMatrix UniformMatrix4x4f;