Example #1
0
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)
}
Example #2
0
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)
}
Example #3
0
func BindArrayData(buffer gl.Buffer, data interface{}) {
	ptr, size := ArrayPtr(data)
	gl.BindBuffer(gl.ARRAY_BUFFER, buffer)
	gl.BufferData(gl.ARRAY_BUFFER, size, ptr, gl.STATIC_DRAW)
}