Added support for setting integer uniforms

This commit is contained in:
nickveri 2013-03-26 18:20:38 +00:00
parent 6b78e2f341
commit fd35ebd4d4
2 changed files with 84 additions and 2 deletions

View File

@ -348,6 +348,69 @@ void CCGLProgram::setUniformLocationWith1i(GLint location, GLint i1)
} }
} }
void CCGLProgram::setUniformLocationWith2i(GLint location, GLint i1, GLint i2)
{
GLint ints[2] = {i1,i2};
bool updated = updateUniformLocation(location, ints, sizeof(ints));
if( updated )
{
glUniform2i( (GLint)location, i1, i2);
}
}
void CCGLProgram::setUniformLocationWith3i(GLint location, GLint i1, GLint i2, GLint i3)
{
GLint ints[3] = {i1,i2,i3};
bool updated = updateUniformLocation(location, ints, sizeof(ints));
if( updated )
{
glUniform3i( (GLint)location, i1, i2, i3);
}
}
void CCGLProgram::setUniformLocationWith4i(GLint location, GLint i1, GLint i2, GLint i3, GLint i4)
{
GLint ints[4] = {i1,i2,i3,i4};
bool updated = updateUniformLocation(location, ints, sizeof(ints));
if( updated )
{
glUniform4i( (GLint)location, i1, i2, i3, i4);
}
}
void CCGLProgram::setUniformLocationWith2iv(GLint location, GLint* ints, unsigned int numberOfArrays)
{
bool updated = updateUniformLocation(location, ints, sizeof(int)*2*numberOfArrays);
if( updated )
{
glUniform2iv( (GLint)location, (GLsizei)numberOfArrays, ints );
}
}
void CCGLProgram::setUniformLocationWith3iv(GLint location, GLint* ints, unsigned int numberOfArrays)
{
bool updated = updateUniformLocation(location, ints, sizeof(int)*3*numberOfArrays);
if( updated )
{
glUniform3iv( (GLint)location, (GLsizei)numberOfArrays, ints );
}
}
void CCGLProgram::setUniformLocationWith4iv(GLint location, GLint* ints, unsigned int numberOfArrays)
{
bool updated = updateUniformLocation(location, ints, sizeof(int)*4*numberOfArrays);
if( updated )
{
glUniform4iv( (GLint)location, (GLsizei)numberOfArrays, ints );
}
}
void CCGLProgram::setUniformLocationWith1f(GLint location, GLfloat f1) void CCGLProgram::setUniformLocationWith1f(GLint location, GLfloat f1)
{ {
bool updated = updateUniformLocation(location, &f1, sizeof(f1)*1); bool updated = updateUniformLocation(location, &f1, sizeof(f1)*1);

View File

@ -129,6 +129,25 @@ public:
/** calls glUniform1i only if the values are different than the previous call for this same shader program. */ /** calls glUniform1i only if the values are different than the previous call for this same shader program. */
void setUniformLocationWith1i(GLint location, GLint i1); void setUniformLocationWith1i(GLint location, GLint i1);
/** calls glUniform2i only if the values are different than the previous call for this same shader program. */
void setUniformLocationWith2i(GLint location, GLint i1, GLint i2);
/** calls glUniform3i only if the values are different than the previous call for this same shader program. */
void setUniformLocationWith3i(GLint location, GLint i1, GLint i2, GLint i3);
/** calls glUniform4i only if the values are different than the previous call for this same shader program. */
void setUniformLocationWith4i(GLint location, GLint i1, GLint i2, GLint i3, GLint i4);
/** calls glUniform2iv only if the values are different than the previous call for this same shader program. */
void setUniformLocationWith2iv(GLint location, GLint* ints, unsigned int numberOfArrays);
/** calls glUniform3iv only if the values are different than the previous call for this same shader program. */
void setUniformLocationWith3iv(GLint location, GLint* ints, unsigned int numberOfArrays);
/** calls glUniform4iv only if the values are different than the previous call for this same shader program. */
void setUniformLocationWith4iv(GLint location, GLint* ints, unsigned int numberOfArrays);
/** calls glUniform1f only if the values are different than the previous call for this same shader program. */ /** calls glUniform1f only if the values are different than the previous call for this same shader program. */
void setUniformLocationWith1f(GLint location, GLfloat f1); void setUniformLocationWith1f(GLint location, GLfloat f1);