コード例 #1
0
ファイル: fontdemo.go プロジェクト: brownman/Go-GLUT
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()
	// Banthar's glu doesn't have this right now.
	// 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.) /* 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()
}
コード例 #2
0
ファイル: simple.go プロジェクト: awpr/Go-GLUT
func display() {
	gl.Clear(gl.COLOR_BUFFER_BIT)
	gl.Begin(gl.TRIANGLES)
	gl.Color3f(0.0, 0.0, 1.0) /* blue */
	gl.Vertex2i(0, 0)
	gl.Color3f(0.0, 1.0, 0.0) /* green */
	gl.Vertex2i(200, 200)
	gl.Color3f(1.0, 0.0, 0.0) /* red */
	gl.Vertex2i(20, 200)
	gl.End()
	gl.Flush() /* Single buffered, so needs a flush. */
}
コード例 #3
0
ファイル: draw2dgl.go プロジェクト: xushiwei/draw2d
func display() {
	gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
	gl.LineWidth(1)
	gc := draw2dgl.NewGraphicContext(width, height)

	gc.Translate(380, 400)
	gc.Scale(1, -1)
	rotate = (rotate + 1) % 360
	gc.Rotate(float64(rotate) * math.Pi / 180)
	gc.Translate(-380, -400)
	interpreter := postscript.NewInterpreter(gc)
	reader := strings.NewReader(postscriptContent)
	lastTime := time.Now()
	interpreter.Execute(reader)
	dt := time.Now().Sub(lastTime)
	log.Printf("Redraw in : %f ms\n", float64(dt)*1e-6)
	gl.Flush() /* Single buffered, so needs a flush. */
	glut.PostRedisplay()
}