コード例 #1
0
ファイル: shader.go プロジェクト: drasich/ridley
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
ファイル: shape.go プロジェクト: velovix/paunch
// 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()
}