Merge pull request #13449 from fusijie/fix_JSB_glGetUniformfv

fixed JSB_glGetUniformfv uniform location is different from index.
This commit is contained in:
子龙山人 2015-08-19 11:42:36 +08:00
commit da9971f04f
1 changed files with 18 additions and 1 deletions

View File

@ -431,13 +431,30 @@ bool JSB_glGetUniformfv(JSContext *cx, uint32_t argc, jsval *vp)
JSB_PRECONDITION2(ok, cx, false, "JSB_glGetUniformfv: Error processing arguments");
GLint activeUniforms;
glGetProgramiv(arg0, GL_ACTIVE_UNIFORMS, &activeUniforms);
GLsizei length;
glGetProgramiv(arg0, GL_ACTIVE_UNIFORM_MAX_LENGTH, &length);
GLchar* namebuffer = new GLchar[length+1];
GLint size = -1;
GLenum type = -1;
glGetActiveUniform(arg0, arg1, length, NULL, &size, &type, namebuffer);
bool isLocationFound = false;
for(int i = 0; i < activeUniforms; ++i)
{
glGetActiveUniform(arg0, i, length, NULL, &size, &type, namebuffer);
if(arg1 == glGetUniformLocation(arg0, namebuffer))
{
isLocationFound = true;
break;
}
}
if(!isLocationFound)
{
size = -1;
type = -1;
}
CC_SAFE_DELETE_ARRAY(namebuffer);
int usize = 0;