Exemplo n.º 1
0
func (polyline *polyLine) drawTriangles(is_looping bool) {
	var overdraw []mgl32.Vec2
	if polyline.overdraw {
		overdraw = polyline.renderOverdraw(is_looping)
	}

	numindices := int(math.Max(float64(len(polyline.vertices)/4), float64(len(overdraw)/4)))
	indices := newAltQuadIndices(numindices)

	prepareDraw(nil)
	bindTexture(gl_state.defaultTexture)
	useVertexAttribArrays(attribflag_pos)
	gl.VertexAttribPointer(attrib_pos, 2, gl.FLOAT, false, 0, gl.Ptr(polyline.vertices))
	gl.DrawElements(gl.TRIANGLES, (len(polyline.vertices)/4)*6, gl.UNSIGNED_SHORT, gl.Ptr(indices))
	if polyline.overdraw {
		c := GetColor()
		colors := polyline.generateColorArray(len(overdraw), c)
		useVertexAttribArrays(attribflag_pos | attribflag_color)
		gl.VertexAttribPointer(attrib_color, 4, gl.UNSIGNED_BYTE, true, 0, gl.Ptr(colors))
		gl.VertexAttribPointer(attrib_pos, 2, gl.FLOAT, false, 0, gl.Ptr(overdraw))
		gl.DrawElements(gl.TRIANGLES, (len(overdraw)/4)*6, gl.UNSIGNED_SHORT, gl.Ptr(indices))
		SetColorC(c)
	}

	indices.Release()
}
Exemplo n.º 2
0
func (buffer *indexBuffer) drawElementsLocal(mode uint32, offset, size int) {
	gl.DrawElements(gl.Enum(mode), size, gl.UNSIGNED_INT, gl.Ptr(&buffer.data[offset]))
}
Exemplo n.º 3
0
func (buffer *indexBuffer) drawElements(mode uint32, offset, size int) {
	buffer.bind()
	defer buffer.unbind()
	gl.DrawElements(gl.Enum(mode), size, gl.UNSIGNED_INT, gl.PtrOffset(offset*4))
}