func SetUniform4F(shader, variable string, vs []float32) error { prog, ok := shader_progs[shader] if !ok { return shaderError(fmt.Sprintf("Tried to set a uniform in an unknown shader '%s'", shader)) } bvariable := []byte(fmt.Sprintf("%s\x00", variable)) loc := gl.GetUniformLocation(prog, (*gl.Char)(unsafe.Pointer(&bvariable[0]))) gl.Uniform4f(loc, gl.Float(vs[0]), gl.Float(vs[1]), gl.Float(vs[2]), gl.Float(vs[3])) return nil }
// SetVariable4f sets a specified variable to the four supplied integers to // be passed into an effect. func (effect *Effect) SetVariable4f(variable string, val1 float32, val2 float32, val3 float32, val4 float32) error { var currEffect gl.Int gl.GetIntegerv(gl.CURRENT_PROGRAM, &currEffect) if gl.Uint(currEffect) != effect.program { return errors.New("effect is not currently in use") } effect.checkUniformVariable(variable) gl.Uniform4f(effect.uniforms[variable], gl.Float(val1), gl.Float(val2), gl.Float(val3), gl.Float(val4)) return nil }