Пример #1
0
func (s *Shader) initAttribute(name string, att *gl.Uint) {
	att_name := gl.GLString(name)
	defer gl.GLStringFree(att_name)
	att_tmp := gl.GetAttribLocation(s.program, att_name)
	if att_tmp == -1 {
		fmt.Println("Error in getting attribute ", gl.GoString(att_name))
	} else {
		*att = gl.Uint(att_tmp)
	}
}
Пример #2
0
// Draw draws the Shape object.
func (shape *Shape) Draw() error {

	gl.BindBuffer(gl.ARRAY_BUFFER, shape.vertexBuffer)
	vertexAttribLoc := gl.GetAttribLocation(paunchEffect.program, gl.GLString("position"))
	gl.VertexAttribPointer(gl.Uint(vertexAttribLoc), 2, gl.FLOAT, gl.FALSE, 0, gl.Offset(nil, 0))
	gl.BindBuffer(gl.ARRAY_BUFFER, 0)

	gl.EnableVertexAttribArray(gl.Uint(vertexAttribLoc))
	gl.DrawArrays(shape.mode, 0, gl.Sizei(shape.size/2))
	gl.DisableVertexAttribArray(gl.Uint(vertexAttribLoc))
	//gl.DisableVertexAttribArray(gl.Uint(1))

	//gl.BindTexture(gl.TEXTURE_2D, 0)

	return checkForErrors()
}