mirror of https://github.com/axmolengine/axmol.git
Added support for setting integer uniforms
This commit is contained in:
parent
6b78e2f341
commit
fd35ebd4d4
|
@ -341,13 +341,76 @@ GLint CCGLProgram::getUniformLocationForName(const char* name)
|
||||||
void CCGLProgram::setUniformLocationWith1i(GLint location, GLint i1)
|
void CCGLProgram::setUniformLocationWith1i(GLint location, GLint i1)
|
||||||
{
|
{
|
||||||
bool updated = updateUniformLocation(location, &i1, sizeof(i1)*1);
|
bool updated = updateUniformLocation(location, &i1, sizeof(i1)*1);
|
||||||
|
|
||||||
if( updated )
|
if( updated )
|
||||||
{
|
{
|
||||||
glUniform1i( (GLint)location, i1);
|
glUniform1i( (GLint)location, 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);
|
||||||
|
|
|
@ -128,6 +128,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);
|
||||||
|
|
Loading…
Reference in New Issue