diff --git a/pixelgl/canvas.go b/pixelgl/canvas.go index c66ab0341f3ee04e78b690e50d0df278dd2e2ffe..8a5be0bf9179529a020532d1fff807f77bd30d18 100644 --- a/pixelgl/canvas.go +++ b/pixelgl/canvas.go @@ -47,13 +47,13 @@ func NewCanvas(bounds pixel.Rect) *Canvas { // attribute variable. If the uniform already exists, including defaults, they will be reassigned // to the new value. The value can be a pointer. func (c *Canvas) SetUniform(Name string, Value interface{}) { - c.shader.SetUniform(Name, Value) + c.shader.setUniform(Name, Value) } // SetFragmentShader allows you to set a new fragment shader on the underlying -// framebuffer. Argument "fs" is the GLSL source, not a filename. -func (c *Canvas) SetFragmentShader(fs string) { - c.shader.fs = fs +// framebuffer. Argument "src" is the GLSL source, not a filename. +func (c *Canvas) SetFragmentShader(src string) { + c.shader.fs = src c.shader.update() } diff --git a/pixelgl/glshader.go b/pixelgl/glshader.go index 2f7544cf025e9638a827d1104ea2e81a5458430f..d1eb3a3de9221148e7a419ba99c2a4c27059e2f3 100644 --- a/pixelgl/glshader.go +++ b/pixelgl/glshader.go @@ -75,20 +75,20 @@ func (gs *glShader) getUniform(Name string) int { // // utime := float32(time.Since(starttime)).Seconds()) // mycanvas.shader.AddUniform("u_time", &utime) -func (gs *glShader) SetUniform(Name string, Value interface{}) { - t, p := getAttrType(Value) - if loc := gs.getUniform(Name); loc > -1 { - gs.uniforms[loc].Name = Name +func (gs *glShader) setUniform(name string, value interface{}) { + t, p := getAttrType(value) + if loc := gs.getUniform(name); loc > -1 { + gs.uniforms[loc].Name = name gs.uniforms[loc].Type = t gs.uniforms[loc].ispointer = p - gs.uniforms[loc].value = Value + gs.uniforms[loc].value = value return } gs.uniforms = append(gs.uniforms, gsUniformAttr{ - Name: Name, + Name: name, Type: t, ispointer: p, - value: Value, + value: value, }) } @@ -102,10 +102,10 @@ func baseShader(c *Canvas) { fs: baseCanvasFragmentShader, } - gs.SetUniform("u_transform", &gs.uniformDefaults.transform) - gs.SetUniform("u_colormask", &gs.uniformDefaults.colormask) - gs.SetUniform("u_bounds", &gs.uniformDefaults.bounds) - gs.SetUniform("u_texbounds", &gs.uniformDefaults.texbounds) + gs.setUniform("u_transform", &gs.uniformDefaults.transform) + gs.setUniform("u_colormask", &gs.uniformDefaults.colormask) + gs.setUniform("u_bounds", &gs.uniformDefaults.bounds) + gs.setUniform("u_texbounds", &gs.uniformDefaults.texbounds) c.shader = gs }