예제 #1
0
func ImageData(img image.Image) (gl.Sizei, gl.Sizei, gl.Enum, gl.Enum, gl.Pointer) {
	switch img := img.(type) {
	case *image.NRGBA:
		return gl.Sizei(img.Rect.Dx()), gl.Sizei(img.Rect.Dy()), gl.RGBA, gl.UNSIGNED_BYTE, gl.Pointer(&img.Pix[0])
	case *image.RGBA:
		return gl.Sizei(img.Rect.Dx()), gl.Sizei(img.Rect.Dy()), gl.RGBA, gl.UNSIGNED_BYTE, gl.Pointer(&img.Pix[0])
	default:
		panic(reflect.TypeOf(img))
	}
	return 0, 0, gl.RGB, gl.UNSIGNED_BYTE, nil
}
예제 #2
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)
}
예제 #3
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)
}