pr 141 review #3 changes, see https://github.com/faiface/pixel/pull/141#pullrequestreview-162261776
This commit is contained in:
parent
fa10844351
commit
e9dfd22ffa
|
@ -47,13 +47,13 @@ func NewCanvas(bounds pixel.Rect) *Canvas {
|
||||||
// attribute variable. If the uniform already exists, including defaults, they will be reassigned
|
// attribute variable. If the uniform already exists, including defaults, they will be reassigned
|
||||||
// to the new value. The value can be a pointer.
|
// to the new value. The value can be a pointer.
|
||||||
func (c *Canvas) SetUniform(Name string, Value interface{}) {
|
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
|
// SetFragmentShader allows you to set a new fragment shader on the underlying
|
||||||
// framebuffer. Argument "fs" is the GLSL source, not a filename.
|
// framebuffer. Argument "src" is the GLSL source, not a filename.
|
||||||
func (c *Canvas) SetFragmentShader(fs string) {
|
func (c *Canvas) SetFragmentShader(src string) {
|
||||||
c.shader.fs = fs
|
c.shader.fs = src
|
||||||
c.shader.update()
|
c.shader.update()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -75,20 +75,20 @@ func (gs *glShader) getUniform(Name string) int {
|
||||||
//
|
//
|
||||||
// utime := float32(time.Since(starttime)).Seconds())
|
// utime := float32(time.Since(starttime)).Seconds())
|
||||||
// mycanvas.shader.AddUniform("u_time", &utime)
|
// mycanvas.shader.AddUniform("u_time", &utime)
|
||||||
func (gs *glShader) SetUniform(Name string, Value interface{}) {
|
func (gs *glShader) setUniform(name string, value interface{}) {
|
||||||
t, p := getAttrType(Value)
|
t, p := getAttrType(value)
|
||||||
if loc := gs.getUniform(Name); loc > -1 {
|
if loc := gs.getUniform(name); loc > -1 {
|
||||||
gs.uniforms[loc].Name = Name
|
gs.uniforms[loc].Name = name
|
||||||
gs.uniforms[loc].Type = t
|
gs.uniforms[loc].Type = t
|
||||||
gs.uniforms[loc].ispointer = p
|
gs.uniforms[loc].ispointer = p
|
||||||
gs.uniforms[loc].value = Value
|
gs.uniforms[loc].value = value
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
gs.uniforms = append(gs.uniforms, gsUniformAttr{
|
gs.uniforms = append(gs.uniforms, gsUniformAttr{
|
||||||
Name: Name,
|
Name: name,
|
||||||
Type: t,
|
Type: t,
|
||||||
ispointer: p,
|
ispointer: p,
|
||||||
value: Value,
|
value: value,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,10 +102,10 @@ func baseShader(c *Canvas) {
|
||||||
fs: baseCanvasFragmentShader,
|
fs: baseCanvasFragmentShader,
|
||||||
}
|
}
|
||||||
|
|
||||||
gs.SetUniform("u_transform", &gs.uniformDefaults.transform)
|
gs.setUniform("u_transform", &gs.uniformDefaults.transform)
|
||||||
gs.SetUniform("u_colormask", &gs.uniformDefaults.colormask)
|
gs.setUniform("u_colormask", &gs.uniformDefaults.colormask)
|
||||||
gs.SetUniform("u_bounds", &gs.uniformDefaults.bounds)
|
gs.setUniform("u_bounds", &gs.uniformDefaults.bounds)
|
||||||
gs.SetUniform("u_texbounds", &gs.uniformDefaults.texbounds)
|
gs.setUniform("u_texbounds", &gs.uniformDefaults.texbounds)
|
||||||
|
|
||||||
c.shader = gs
|
c.shader = gs
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue