示例#1
0
文件: render.go 项目: vova616/mater
func DrawLine(start, end vect.Vect) {
	gl.Begin(gl.LINES)
	defer gl.End()

	gl.Vertex2d(start.X, start.Y)
	gl.Vertex2d(end.X, end.Y)
}
示例#2
0
文件: render.go 项目: vova616/mater
func DrawQuad(upperLeft, lowerRight vect.Vect, filled bool) {
	if filled {
		gl.Begin(gl.QUADS)
	} else {
		gl.Begin(gl.LINE_LOOP)
	}
	defer gl.End()

	gl.Vertex2d(upperLeft.X, upperLeft.Y)
	gl.Vertex2d(upperLeft.X, lowerRight.Y)
	gl.Vertex2d(lowerRight.X, lowerRight.Y)
	gl.Vertex2d(lowerRight.X, upperLeft.Y)
}
示例#3
0
文件: render.go 项目: vova616/mater
func DrawPoly(vertices []vect.Vect, vertCount int, filled bool) {
	if filled {
		gl.Begin(gl.TRIANGLE_FAN)
		gl.Vertex2d(vertices[0].X, vertices[0].Y)
	} else {
		gl.Begin(gl.LINE_LOOP)
	}
	defer gl.End()

	for i := 0; i < vertCount; i++ {
		v := vertices[i]
		gl.Vertex2d(v.X, v.Y)
	}
}
示例#4
0
文件: render.go 项目: vova616/mater
func DrawCircle(pos vect.Vect, radius float64, filled bool) {
	if filled {
		gl.Begin(gl.TRIANGLE_FAN)
		gl.Vertex2d(pos.X, pos.Y)
	} else {
		gl.Begin(gl.LINE_LOOP)
	}
	defer gl.End()

	var d float64
	for i := 0.0; i <= 360; i += circlestep {
		d = deg2grad * i
		gl.Vertex2d(pos.X+math.Cos(d)*radius, pos.Y+math.Sin(d)*radius)
	}
}