Bug in Lua binding of GLProgramState

local shader = cc.GLProgram:createWithByteArrays(vert, frag) 
local state = cc.GLProgramState:create(shader)localstate = cc.GLProgramState:create(shader)
state:setUniformFloat("hue", 0)
state:setUniFormFloat("saturation",1)
state:setUniFormFloat("lightness",1)

run in windows and get error:

error:
     cc.GLProgramState:setUniformFloat argument #2 is 'string'; 'number' expected.

[LUA-print] ----------------------------------------
[LUA-print] LUA ERROR: [string ".\hello2.lua"]:90: attempt to call method 'setUniFormFloat' (a nil value)

[LUA-print] stack traceback:
    [string ".\src/hello.lua"]:15: in function 'setUniFormFloat'
    [string ".\hello2.lua"]:90: in main chunk
    [C]: in function 'require'
    [string ".\src/hello.lua"]:45: in function <[string ".\src/hello.lua"]:38>
    [C]: in function 'xpcall'
    [string ".\src/hello.lua"]:223: in main chunk
    [C]: in function 'require'
    [string "require 'src/hello.lua'"]:1: in main chunk
[LUA-print] ----------------------------------------

It looks like there are some errors in binding overload functions.
the first “setUniformFloat” report the argument error, but it work fine.
the second “setUniformFloat” will report can’t find the setUniformFloat function.

My version is v3.4. Thanks!

cc.GLProgramState:setUniformFloat argument #2 is ‘string’; ‘number’ expected

AFAIK the first error is a warning but don’t know about the second error. The following code works for me. Hope it helps.

local program = cc.GLProgram:createWithByteArrays(vertSource2, fragDistord3)
program:bindAttribLocation(cc.ATTRIBUTE_NAME_POSITION, cc.VERTEX_ATTRIB_POSITION)
program:bindAttribLocation(cc.ATTRIBUTE_NAME_TEX_COORD, cc.VERTEX_ATTRIB_TEX_COORD)
program:link()
program:updateUniforms()

local glProgramState = cc.GLProgramState:getOrCreateWithGLProgram(program)

local sprite = cc.Sprite:create(filename)
sprite:setGLProgram(program)
sprite:setGLProgramState(glProgramState)
glProgramState:setUniformVec4("u_color",cc.vec4(1,1,1,1))
glProgramState:setUniformFloat("threshold",0.7)
glProgramState:setUniformFloat("test",0.7)

Thank you! I pack the uniforms into a vec3 and it works.

the second errors is still confusing, i will test it on other diveces and system.

@laurentzubiaur.
setUniFormFloat is not the same as setUniformFloat.Have you found that the difference between them? UniForm -> Uniform.

@samuele3hu I didn’t notice that. It seems that only setUniformFloat is correct. I guest it must be a typo from @ffxhina. That explains the error “attempt to call method ‘setUniFormFloat’ (a nil value)”. Thanks!

Can you describe how to pack the uniforms into a vec3? Thanks!

i have the same problem with you,Can you describe how to pack the uniforms into a vec3?