(bind-func shader_update_light
(lambda (shader:ShaderProgram* position target angle power:float ambient diffuse specular)
;(vprint position 4)
;(vprint target 4)
(glUniform1f (glGetUniformLocation (id shader) "ConstantAttenuation") 1.0)
(glUniform1f (glGetUniformLocation (id shader) "LinearAttenuation") 0.0)
(glUniform1f (glGetUniformLocation (id shader) "QuadraticAttenuation") 0.0)
(glUniform1f (glGetUniformLocation (id shader) "SpotExponent") power)
(glUniform1f (glGetUniformLocation (id shader) "SpotAngle") (- 1.0 (/ angle 180.0)))
(glUniform4fv (glGetUniformLocation (id shader) "LightPos") 1 position)
(glUniform4fv (glGetUniformLocation (id shader) "LightAmbient") 1 ambient)
(glUniform4fv (glGetUniformLocation (id shader) "LightSpecular") 1 specular)
(glUniform4fv (glGetUniformLocation (id shader) "LightDiffuse") 1 diffuse)
(let ((direction:float* (salloc 4))
(tmp:float* (salloc 4)))
(vvsub target position 3 tmp)
(vnormalise tmp 3 direction)
(pset! direction 3 0.0)
(glUniform4fv (glGetUniformLocation (id shader) "SpotDir") 1 direction))
void))