Exemplo n.º 1
0
// CreateProgram creates, compiles, and links a gl.Program.
func CreateProgram(vertexSrc, fragmentSrc string) (gl.Program, error) {
	program := gl.CreateProgram()
	if program.Value == 0 {
		return gl.Program{}, fmt.Errorf("glutil: no programs available")
	}

	vertexShader, err := loadShader(gl.VERTEX_SHADER, vertexSrc)
	if err != nil {
		return gl.Program{}, err
	}
	fragmentShader, err := loadShader(gl.FRAGMENT_SHADER, fragmentSrc)
	if err != nil {
		gl.DeleteShader(vertexShader)
		return gl.Program{}, err
	}

	gl.AttachShader(program, vertexShader)
	gl.AttachShader(program, fragmentShader)
	gl.LinkProgram(program)

	// Flag shaders for deletion when program is unlinked.
	gl.DeleteShader(vertexShader)
	gl.DeleteShader(fragmentShader)

	if gl.GetProgrami(program, gl.LINK_STATUS) == 0 {
		defer gl.DeleteProgram(program)
		return gl.Program{}, fmt.Errorf("glutil: %s", gl.GetProgramInfoLog(program))
	}
	return program, nil
}
Exemplo n.º 2
0
func stop() {
	stopAudio()

	gl.DeleteProgram(program)
	gl.DeleteBuffer(positionbuf)
	gl.DeleteBuffer(pointsizebuf)
}
Exemplo n.º 3
0
func (e *Engine) Stop() {
	gl.DeleteProgram(e.shader.program)
	for _, buf := range e.shape.Objs {
		gl.DeleteBuffer(buf.coord)
		gl.DeleteBuffer(buf.uvcoord)
		gl.DeleteBuffer(buf.normal)
	}
}
Exemplo n.º 4
0
func stop() {
	gl.DeleteProgram(glimage.program)
	gl.DeleteBuffer(glimage.quadXY)
	gl.DeleteBuffer(glimage.quadUV)

	texmap.Lock()
	for _, t := range texmap.texs {
		if t.gltex.Value != 0 {
			gl.DeleteTexture(t.gltex)
		}
		t.gltex = gl.Texture{}
	}
	texmap.Unlock()
}
Exemplo n.º 5
0
func onStop() {
	gl.DeleteProgram(program)
	gl.DeleteBuffer(swasBuffer)
}
Exemplo n.º 6
0
func (e *Engine) Stop() {
	gl.DeleteProgram(e.shader.program)
	gl.DeleteBuffer(e.shape.buf)
}
Exemplo n.º 7
0
func (e *Engine) Stop() {
	gl.DeleteProgram(e.shader.program)
	for _, buf := range e.shape.bufs {
		gl.DeleteBuffer(buf.coord)
	}
}
Exemplo n.º 8
0
func onStop() {
	gl.DeleteProgram(program)
	gl.DeleteBuffer(buf)
}
Exemplo n.º 9
0
//停止时触发,清理
func onStop() {
	gl.DeleteProgram(program)
	gl.DeleteBuffer(positionbuf)
	gl.DeleteBuffer(colorbuf)
}
Exemplo n.º 10
0
func (shader *shader) Close() error {
	gl.DeleteProgram(shader.program)
	return nil
}