Esempio n. 1
0
func (a *app) draw(t time.Time) {
	gl.Clear(gl.COLOR_BUFFER_BIT)
	img := a.img
	w := img.Rect.Dx()
	h := img.Rect.Dy()
	gl.ActiveTexture(gl.TEXTURE0)
	upload(1, img.Y, img.YStride, w, h)
	gl.ActiveTexture(gl.TEXTURE1)
	upload(2, img.Cb, img.CStride, w/2, h/2)
	gl.ActiveTexture(gl.TEXTURE2)
	upload(3, img.Cr, img.CStride, w/2, h/2)
	if *blend {
		pimg := a.pimg
		gl.Uniform1f(a.factorloc, factor(t,
			a.tbase.Add(pimg.Timecode),
			a.tbase.Add(img.Timecode)))
		gl.ActiveTexture(gl.TEXTURE3)
		upload(4, pimg.Y, pimg.YStride, w, h)
		gl.ActiveTexture(gl.TEXTURE4)
		upload(5, pimg.Cb, pimg.CStride, w/2, h/2)
		gl.ActiveTexture(gl.TEXTURE5)
		upload(6, pimg.Cr, pimg.CStride, w/2, h/2)
	}
	gl.DrawArrays(gl.TRIANGLE_STRIP, 0, 4)
}
Esempio n. 2
0
func SetUniformF(shader, variable string, f 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.Uniform1f(loc, gl.Float(f))
	return nil
}
Esempio n. 3
0
func SetUniformF(shader, variable string, f float32) {
	prog, ok := shader_progs[shader]
	if !ok {
		if !warned_names[shader] {
			Warn().Printf("Tried to set a uniform in an unknown shader '%s'", shader)
			warned_names[shader] = true
		}
		return
	}
	bvariable := []byte(fmt.Sprintf("%s\x00", variable))
	loc := gl.GetUniformLocation(prog, (*gl.Char)(unsafe.Pointer(&bvariable[0])))
	gl.Uniform1f(loc, f)
}
Esempio n. 4
0
// SetVariablef sets a specified variable to the supplied integer to be passed
// into an effect.
func (effect *Effect) SetVariablef(variable string, val 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.Uniform1f(effect.uniforms[variable], gl.Float(val))
	return nil
}