diff --git a/cocos/2d/CCGLProgram.cpp b/cocos/2d/CCGLProgram.cpp index 83da8f9bdc..ccc908d646 100644 --- a/cocos/2d/CCGLProgram.cpp +++ b/cocos/2d/CCGLProgram.cpp @@ -512,6 +512,24 @@ void GLProgram::setUniformLocationWith4fv(GLint location, GLfloat* floats, unsig } } +void GLProgram::setUniformLocationWithMatrix2fv(GLint location, GLfloat* matrixArray, unsigned int numberOfMatrices) { + bool updated = updateUniformLocation(location, matrixArray, sizeof(float)*4*numberOfMatrices); + + if( updated ) + { + glUniformMatrix2fv( (GLint)location, (GLsizei)numberOfMatrices, GL_FALSE, matrixArray); + } +} + +void GLProgram::setUniformLocationWithMatrix3fv(GLint location, GLfloat* matrixArray, unsigned int numberOfMatrices) { + bool updated = updateUniformLocation(location, matrixArray, sizeof(float)*9*numberOfMatrices); + + if( updated ) + { + glUniformMatrix3fv( (GLint)location, (GLsizei)numberOfMatrices, GL_FALSE, matrixArray); + } +} + void GLProgram::setUniformLocationWithMatrix4fv(GLint location, GLfloat* matrixArray, unsigned int numberOfMatrices) { diff --git a/cocos/2d/CCGLProgram.h b/cocos/2d/CCGLProgram.h index cea1add0b2..44b5676dea 100644 --- a/cocos/2d/CCGLProgram.h +++ b/cocos/2d/CCGLProgram.h @@ -198,6 +198,12 @@ public: /** calls glUniform4fv only if the values are different than the previous call for this same shader program. */ void setUniformLocationWith4fv(GLint location, GLfloat* floats, unsigned int numberOfArrays); + /** calls glUniformMatrix2fv only if the values are different than the previous call for this same shader program. */ + void setUniformLocationWithMatrix2fv(GLint location, GLfloat* matrixArray, unsigned int numberOfMatrices); + + /** calls glUniformMatrix3fv only if the values are different than the previous call for this same shader program. */ + void setUniformLocationWithMatrix3fv(GLint location, GLfloat* matrixArray, unsigned int numberOfMatrices); + /** calls glUniformMatrix4fv only if the values are different than the previous call for this same shader program. */ void setUniformLocationWithMatrix4fv(GLint location, GLfloat* matrixArray, unsigned int numberOfMatrices);