コード例 #1
0
ファイル: pipeline.go プロジェクト: GlenKelley/go-glutil
func DrawGeometry(geo *Geometry, vertexAttribute gl.AttributeLocation, vao gl.VertexArrayObject) {
	gl.BindBuffer(gl.ARRAY_BUFFER, geo.VertexBuffer)
	gl.BindVertexArray(vao)
	gl.VertexAttribPointer(vertexAttribute, 3, gl.FLOAT, gl.FALSE, 12, nil)
	gl.EnableVertexAttribArray(vertexAttribute)
	for _, elem := range geo.Elements {
		gl.BindBuffer(gl.ELEMENT_ARRAY_BUFFER, elem.Buffer)
		gl.DrawElements(elem.DrawType, gl.Sizei(elem.Count), gl.UNSIGNED_SHORT, nil)
		PanicOnError()
	}
	gl.DisableVertexAttribArray(vertexAttribute)
}
コード例 #2
0
ファイル: main.go プロジェクト: GlenKelley/portal
func (r *Receiver) DrawGeometry(geo *gtk.Geometry, vertexAttribute gl.AttributeLocation, lines bool) {
	gl.BindBuffer(gl.ARRAY_BUFFER, geo.VertexBuffer)
	gl.BindVertexArray(r.Data.Vao)
	gl.VertexAttribPointer(vertexAttribute, 3, gl.FLOAT, gl.FALSE, 12, nil)
	gl.EnableVertexAttribArray(vertexAttribute)

	for _, elem := range geo.Elements {
		if lines == (elem.DrawType == gl.LINES) {
			gl.BindBuffer(gl.ELEMENT_ARRAY_BUFFER, elem.Buffer)
			gl.DrawElements(elem.DrawType, gl.Sizei(elem.Count), gl.UNSIGNED_SHORT, nil)
			gtk.PanicOnError()
		}
	}
	gl.DisableVertexAttribArray(vertexAttribute)
}