Hi,
I’m trying to update uniforms of my shader:
void TextureLoader::updateUniforms()
{
//updating Vec3 and float, forks fine
renderSprite->getGLProgramState()->setUniformVec3("shadowsShift", shadowShift);
renderSprite->getGLProgramState()->setUniformFloat("overlap", overlap);
//...
//updating float arrays, doesn't work
GLProgram* glprogram = renderSprite->getGLProgramState()->getGLProgram();
GLfloat params[7] = { 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f};
GLuint location = glGetUniformLocation(glprogram->getProgram(), "hueShift");
glprogram->setUniformLocationWith1fv(location, params, 7);
}
Updating of float array doen’t work in distinction from Vec3 and floats.
Here’s how I’m calling this function:
void TextureLoader::visit(Renderer *renderer, const Mat4 &transform, uint32_t flags)
{
//updating uniforms
command.init(_globalZOrder);
command.func = CC_CALLBACK_0(TextureLoader::updateUniforms, this);
renderer->addCommand(&command);
//texture rendering
renderLayer->beginWithClear(0, 0, 0, 0);
renderSprite->visit(renderer, transform, flags);
renderLayer->end();
}
When I create shader and set float array in a same way as above at first time, everything is all right. But when I’m trying to update this array, this doesn’t work and has no effect. Vec3 and float updating always works fine.
How can I update uniform float arrays?
Thanks in advance.