Exemplo n.º 1
0
func display() {
	gl.Clear(gl.COLOR_BUFFER_BIT)
	bitmap_output(40, 35, "This is written in a GLUT bitmap font.", glut.BITMAP_TIMES_ROMAN_24)
	bitmap_output(30, 210, "More bitmap text is a fixed 9 by 15 font.", glut.BITMAP_9_BY_15)
	bitmap_output(70, 240, "                Helvetica is yet another bitmap font.", glut.BITMAP_HELVETICA_18)

	gl.MatrixMode(gl.PROJECTION)
	gl.PushMatrix()
	gl.LoadIdentity()
	glu.Perspective(40.0, 1.0, 0.1, 20.0)
	gl.MatrixMode(gl.MODELVIEW)
	gl.PushMatrix()
	glu.LookAt(0.0, 0.0, 4.0, /* eye is at (0,0,30) */
		0.0, 0.0, 0.0, /* center is at (0,0,0) */
		0.0, 1.0, 0.0) /* up is in postivie Y direction */
	gl.PushMatrix()
	gl.Translatef(0, 0, -4)
	gl.Rotatef(50, 0, 1, 0)
	stroke_output(-2.5, 1.1, "  This is written in a", glut.STROKE_ROMAN)
	stroke_output(-2.5, 0, " GLUT stroke font.", glut.STROKE_ROMAN)
	stroke_output(-2.5, -1.1, "using 3D perspective.", glut.STROKE_ROMAN)
	gl.PopMatrix()
	gl.MatrixMode(gl.MODELVIEW)
	gl.PopMatrix()
	gl.MatrixMode(gl.PROJECTION)
	gl.PopMatrix()
	gl.MatrixMode(gl.MODELVIEW)
	gl.Flush()
}
Exemplo n.º 2
0
func drawShip(angle float32) {
	gl.PushMatrix()
	gl.Translatef(x, y, 0.0)
	gl.Rotatef(angle, 0.0, 0.0, 1.0)
	if thrust {
		gl.Color3f(1.0, 0.0, 0.0)
		gl.Begin(gl.LINE_STRIP)
		gl.Vertex2f(-0.75, -0.5)
		gl.Vertex2f(-1.75, 0)
		gl.Vertex2f(-0.75, 0.5)
		gl.End()
	}
	gl.Color3f(1.0, 1.0, 0.0)
	gl.Begin(gl.LINE_LOOP)
	gl.Vertex2f(2.0, 0.0)
	gl.Vertex2f(-1.0, -1.0)
	gl.Vertex2f(-0.5, 0.0)
	gl.Vertex2f(-1.0, 1.0)
	gl.Vertex2f(2.0, 0.0)
	gl.End()
	if shield {
		gl.Color3f(0.1, 0.1, 1.0)
		gl.Begin(gl.LINE_LOOP)
		for rad := 0.0; rad < 12.0; rad += 1.0 {
			gl.Vertex2f(
				float32(2.3*math.Cos(2*float64(rad)/math.Pi)+0.2),
				float32(2.0*math.Sin(2*float64(rad)/math.Pi)))
		}
		gl.End()
	}
	gl.PopMatrix()
}
Exemplo n.º 3
0
func stroke_output(x, y float32, str string, font glut.StrokeFont) {
	gl.PushMatrix()
	gl.Translatef(x, y, 0)
	gl.Scalef(0.005, 0.005, 0.005)
	for _, ch := range str {
		font.Character(ch)
	}
	gl.PopMatrix()
}