From e9dfd22ffa4b6722d34870b6c2f1a51c9b052975 Mon Sep 17 00:00:00 2001 From: Brandon Date: Sat, 6 Oct 2018 10:27:47 -0600 Subject: [PATCH] pr 141 review #3 changes, see https://github.com/faiface/pixel/pull/141#pullrequestreview-162261776 --- pixelgl/canvas.go | 8 ++++---- pixelgl/glshader.go | 22 +++++++++++----------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/pixelgl/canvas.go b/pixelgl/canvas.go index c66ab03..8a5be0b 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 2f7544c..d1eb3a3 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 }