Beispiel #1
0
func EnableShader(name string) {
	prog_obj, ok := shader_progs[name]
	if ok {
		gl.UseProgram(prog_obj)
	} else {
		gl.UseProgram(0)
		if name != "" && !warned_names[name] {
			Warn().Printf("Tried to use unknown shader '%s'", name)
			warned_names[name] = true
		}
	}
}
Beispiel #2
0
func EnableShader(name string) error {
	if name == "" {
		gl.UseProgram(0)
		return nil
	}
	prog_obj, ok := shader_progs[name]
	if !ok {
		return shaderError(fmt.Sprintf("Tried to use unknown shader '%s'", name))
	}
	gl.UseProgram(prog_obj)
	return nil
}
Beispiel #3
0
func shinit() gl.Int {
	vs := loadShader(gl.VERTEX_SHADER, vss)
	var sfs string
	if *blend {
		sfs = bfss
	} else {
		sfs = fss
	}
	fs := loadShader(gl.FRAGMENT_SHADER, sfs)
	prg := gl.CreateProgram()
	gl.AttachShader(prg, vs)
	gl.AttachShader(prg, fs)
	gl.LinkProgram(prg)
	var l int
	if *blend {
		l = 6
	} else {
		l = 3
	}
	gl.UseProgram(prg)
	names := []string{"yt1", "cbt1", "crt1", "yt0", "cbt0", "crt0"}
	for i := 0; i < l; i++ {
		loc := gl.GetUniformLocation(prg, gl.GLString(names[i]))
		gl.Uniform1i(loc, gl.Int(i))
	}
	return gl.GetUniformLocation(prg, gl.GLString("factor"))
}
Beispiel #4
0
// UseEffect sets the given Effect object for use in the following draw
// commands.
func UseEffect(effect *Effect) error {

	gl.UseProgram(effect.program)

	effect.uniforms = make(map[string]gl.Int)

	paunchEffect = effect

	return checkForErrors()
}
Beispiel #5
0
func (s *Shader) use() {
	gl.UseProgram(s.program)
}
Beispiel #6
0
// DisableEffects disables all effects.
func DisableEffects() {

	gl.UseProgram(0)
	paunchEffect = nil
}