예제 #1
0
func drawFrame() {

	gl.LoadIdentity()
	gl.LineWidth(5.0)
	gl.Enable(gl.POINT_SMOOTH)
	gl.Enable(gl.LINE_SMOOTH)

	gl.Color4f(gl.GLfloat(FrameColor[0]), gl.GLfloat(FrameColor[1]), gl.GLfloat(FrameColor[2]), 0.1)

	m := PlayArea

	t := 1.0 * m
	b := -1.0 * m
	r := 1.0 * m
	l := -1.0 * m

	gl.Begin(gl.LINE_STRIP)

	zo := -5.0

	gl.Vertex3f(gl.GLfloat(l), gl.GLfloat(t), gl.GLfloat(zo))
	gl.Vertex3f(gl.GLfloat(r), gl.GLfloat(t), gl.GLfloat(zo))
	gl.Vertex3f(gl.GLfloat(r), gl.GLfloat(b), gl.GLfloat(zo))
	gl.Vertex3f(gl.GLfloat(l), gl.GLfloat(b), gl.GLfloat(zo))
	gl.Vertex3f(gl.GLfloat(l), gl.GLfloat(t), gl.GLfloat(zo))

	gl.End()

}
예제 #2
0
func main() {
	glut.Init()
	glut.InitDisplayMode(glut.SINGLE | glut.RGB)
	glut.InitWindowSize(465, 250)
	glut.CreateWindow("GLUT bitmap & stroke font example")
	gl.ClearColor(1.0, 1.0, 1.0, 1.0)
	gl.Color3f(0, 0, 0)
	gl.LineWidth(3.0)
	glut.DisplayFunc(display)
	glut.ReshapeFunc(reshape)
	glut.MainLoop()
}
예제 #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()
}
예제 #4
0
func drawCircle(t *trigger) {

	radius := float64(t.Size)
	pos := t.Pos

	gl.LoadIdentity()
	gl.Color4f(gl.GLfloat(t.Col[0]), gl.GLfloat(t.Col[1]), gl.GLfloat(t.Col[2]), gl.GLfloat(t.Col[3]))

	gl.LineWidth(2.0)
	gl.Translatef(gl.GLfloat(pos.X), gl.GLfloat(pos.Y), gl.GLfloat(pos.Z))

	gl.Enable(gl.BLEND)
	gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)

	gl.Begin(gl.POLYGON)

	for i := 0; i < 360; i++ {
		var degInRad float64 = float64(i) * DEG2RAD
		gl.Vertex3f(gl.GLfloat(math.Cos(degInRad)*radius), gl.GLfloat(math.Sin(degInRad)*radius), gl.GLfloat(0.0))
	}

	gl.End()
	gl.Disable(gl.BLEND)
}