示例#1
0
文件: fontdemo.go 项目: tmc/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()
	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()
}
示例#2
0
文件: glfps.go 项目: shogg/glfps
func drawDigits(x, y int, digits []int8) {

	s := sdl.GetVideoSurface()
	lft, rgt, btm, top := 0.0, float64(s.W), float64(s.H), 0.0

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

	gl.MatrixMode(gl.PROJECTION)
	gl.PushMatrix()
	gl.LoadIdentity()
	gl.Ortho(lft, rgt, btm, top, 0.0, 1.0)
	gl.MatrixMode(gl.MODELVIEW)
	gl.PushMatrix()
	gl.LoadIdentity()

	w := digitImages[0].Rect.Dx()
	for i := 0; i < len(digits); i++ {
		img := digitImages[digits[i]]
		drawImage(x-w*i-i, y, img)
	}

	gl.MatrixMode(gl.MODELVIEW)
	gl.PopMatrix()

	gl.MatrixMode(gl.PROJECTION)
	gl.PopMatrix()
}
示例#3
0
func Draw() {
	gl.Clear(gl.COLOR_BUFFER_BIT)

	gl.PushMatrix()
	defer gl.PopMatrix()

	gl.Color4f(0, 1, 0, .5)
	DrawCircle(vect.Vect{ScreenSize.X / 2, ScreenSize.Y / 2}, ScreenSize.Y/2.0-5.0, false)

	if Settings.Paused {
		gl.Color3f(1, 1, 1)
		RenderFontAt("Paused", 20, 30)
	}

	//draw collision objects

	gl.PushMatrix()

	gl.Translated(ScreenSize.X/2, ScreenSize.Y/2, 0)
	gl.Scaled(Settings.Scale, Settings.Scale, 1)

	DrawDebugData(space)

	gl.PopMatrix()
}
示例#4
0
文件: render.go 项目: esnowkropla/dep
func general_render(s *list.List, c *camera) {
	gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
	gl.PushMatrix()
	//gl.Translatef(float32(c.X), float32(c.Y), float32(c.Z))
	glu.LookAt(c.pos.X, c.pos.Y, c.pos.Z, c.front.X, c.front.Y, c.front.Z, c.top.X, c.top.Y, c.top.Z)

	for e := s.Front(); e != nil; e = e.Next() {
		gl.PushMatrix()
		v := e.Value.(*sprite)
		v.render()
		gl.PopMatrix()
	}
	gl.PopMatrix()
}
示例#5
0
func (self *Wolf) Draw(center Vectorf, selectedBlockFace *BlockFace) {
	gl.PushMatrix()
	gl.Translatef(float32(self.position[XAXIS]), float32(self.position[YAXIS]), float32(self.position[ZAXIS]))
	gl.Rotated(self.Heading(), 0.0, 1.0, 0.0)
	WolfModel.GLDraw()
	gl.PopMatrix()
}
示例#6
0
func (self *Inventory) DrawItemSlot(t int64, r Rect) {
	gl.PushMatrix()
	gl.LoadIdentity()

	gl.Color4ub(16, 16, 16, 255)
	gl.Begin(gl.QUADS)
	gl.Vertex2d(r.x, r.y)
	gl.Vertex2d(r.x+r.sizex, r.y)
	gl.Vertex2d(r.x+r.sizex, r.y+r.sizey)
	gl.Vertex2d(r.x, r.y+r.sizey)
	gl.End()

	gl.Color4ub(6, 6, 6, 255)
	gl.Begin(gl.LINES)
	gl.Vertex2d(r.x, r.y)
	gl.Vertex2d(r.x+r.sizex, r.y)
	gl.Vertex2d(r.x, r.y)
	gl.Vertex2d(r.x, r.y+r.sizey)
	gl.End()

	gl.Color4ub(64, 64, 64, 255)
	gl.Begin(gl.LINES)
	gl.Vertex2d(r.x+r.sizex, r.y)
	gl.Vertex2d(r.x+r.sizex, r.y+r.sizey)
	gl.Vertex2d(r.x, r.y+r.sizey)
	gl.Vertex2d(r.x+r.sizex, r.y+r.sizey)
	gl.End()

	gl.PopMatrix()
}
示例#7
0
文件: layout.go 项目: glenn-brown/vu
func (x spinner) Render(w, h, d float64) {
	gl.PushMatrix()
	t := time.Now().Sub(x.start).Seconds()
	gl.Rotated(120*surge(t), w, h, d)
	x.child.Render(w, h, d)
	gl.PopMatrix()
}
示例#8
0
func (self *Pause) Draw(t int64) {
	gl.MatrixMode(gl.MODELVIEW)
	gl.PushMatrix()
	gl.LoadIdentity()

	gl.Disable(gl.DEPTH_TEST)
	gl.Disable(gl.LIGHTING)
	gl.Disable(gl.LIGHT0)
	gl.Disable(gl.LIGHT1)

	gl.Color4ub(0, 0, 0, 240)

	gl.Begin(gl.QUADS)
	gl.Vertex2f(float32(viewport.lplane), float32(viewport.bplane))
	gl.Vertex2f(float32(viewport.rplane), float32(viewport.bplane))
	gl.Vertex2f(float32(viewport.rplane), float32(viewport.tplane))
	gl.Vertex2f(float32(viewport.lplane), float32(viewport.tplane))
	gl.End()

	str := "paused"
	h, w := pauseFont.Measure(str)

	// x := (viewport.rplane - viewport.lplane - w) / 2
	// y := (viewport.tplane - viewport.bplane - h) / 2
	gl.Translated(-w/2, -h/2, 0)
	pauseFont.Print(str)

	gl.PopMatrix()

}
示例#9
0
func (self *Picker) DrawPlayerItems(t int64) {

	gl.PushMatrix()
	gl.LoadIdentity()

	for i := 0; i < 5; i++ {

		item := ThePlayer.equippedItems[i]
		if item != ITEM_NONE {
			angle := -(float64(i) + 1.5) * math.Pi / 4
			gl.LoadIdentity()
			x := self.x - self.actionItemRadius*float32(math.Sin(angle))
			y := self.y + self.actionItemRadius*float32(math.Cos(angle))
			gl.Translatef(x, y, 0)

			gl.Rotatef(360*float32(math.Sin(float64(t)/1e10+float64(i))), 1.0, 0.0, 0.0)
			gl.Rotatef(360*float32(math.Cos(float64(t)/1e10+float64(i))), 0.0, 1.0, 0.0)
			gl.Rotatef(360*float32(math.Sin(float64(t)/1e10+float64(i))), 0.0, 0.0, 1.0)
			gl.Scalef(blockscale, blockscale, blockscale)
			gVertexBuffer.Reset()
			TerrainCube(gVertexBuffer, 0, 0, 0, [18]uint16{}, item, FACE_NONE)
			gVertexBuffer.RenderDirect(false)

			gl.LoadIdentity()
			gl.Translatef(x-17*PIXEL_SCALE, y-19*PIXEL_SCALE, 20)
			consoleFont.Print(fmt.Sprintf("%d", ThePlayer.inventory[item]))

		}
	}
	gl.PopMatrix()

}
示例#10
0
func (self *Picker) Draw(t int64) {

	gl.MatrixMode(gl.MODELVIEW)
	gl.PushMatrix()

	gl.LoadIdentity()

	gl.Disable(gl.DEPTH_TEST)
	gl.Disable(gl.LIGHTING)
	gl.Disable(gl.LIGHT0)
	gl.Disable(gl.LIGHT1)

	gl.Begin(gl.TRIANGLE_FAN)
	gl.Color4ub(0, 0, 0, 128)
	gl.Vertex2f(self.x, self.y)
	for angle := float64(0); angle <= 2*math.Pi; angle += math.Pi / 2 / 10 {
		gl.Vertex2f(self.x-float32(math.Sin(angle))*self.radius, self.y+float32(math.Cos(angle))*self.radius)
	}
	gl.End()

	self.DrawItemHighlight(t, ThePlayer.currentAction)
	self.DrawPlayerItems(t, true)

	gl.PopMatrix()

}
示例#11
0
文件: layout.go 项目: glenn-brown/vu
func (c cube) Render(w, h, d float64) {
	x := math.Min(math.Min(w, h), d)
	gl.PushMatrix()
	gl.Translated((w-x)/2.0, (h-x)/2.0, (d-x)/2.0)
	c.child.Render(x, x, x)
	gl.PopMatrix()
}
示例#12
0
func (self *Inventory) DrawItem(t int64, quantity uint16, itemid ItemId, x float64, y float64) {
	gl.PushMatrix()
	gl.LoadIdentity()

	// angle := -90.0
	const blocksize = float32(0.3)

	gl.Translated(x, y, 0)

	//gl.Rotated(angle, 1.0, 0.0, 0.0)
	gl.Rotated(90, 1.0, 0.0, 0.0)
	gl.Rotated(30*math.Sin(float64(t)/1e9+float64(itemid)/2), 0.0, 1.0, 0.0)
	gl.Scalef(blocksize, blocksize, blocksize)
	self.drawBuffer.Reset()

	if itemid < 256 {
		TerrainCube(self.drawBuffer, Vectori{}, [18]BlockId{BLOCK_DIRT, BLOCK_DIRT, BLOCK_DIRT, BLOCK_DIRT, BLOCK_AIR, BLOCK_DIRT, BLOCK_AIR, BLOCK_AIR, BLOCK_AIR, BLOCK_AIR, BLOCK_AIR, BLOCK_AIR, BLOCK_AIR, BLOCK_AIR, BLOCK_AIR, BLOCK_AIR, BLOCK_AIR}, NewBlockDefault(BlockId(itemid)), FACE_NONE)
	} else {
		RenderItemFlat(self.drawBuffer, Vectori{}, BlockId(itemid))
	}
	self.drawBuffer.RenderDirect(false)

	gl.LoadIdentity()
	gl.Translated(x+2*PIXEL_SCALE-48*PIXEL_SCALE*float64(blocksize), y-7*PIXEL_SCALE-48*PIXEL_SCALE*float64(blocksize), 0)
	inventoryItemFont.Print(fmt.Sprintf("%d", quantity))

	gl.PopMatrix()

}
示例#13
0
文件: asteroids.go 项目: tmc/glut
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()
}
示例#14
0
文件: layout.go 项目: glenn-brown/vu
func (x *wiggler) Render(w, h, d float64) {
	gl.PushMatrix()
	t := time.Now().Sub(x.start).Seconds()
	dx := w / 10.0 * math.Sin(t)
	gl.Translated(dx, 0, 0)
	x.child.Render(w, h, d)
	gl.PopMatrix()
}
示例#15
0
文件: fontdemo.go 项目: tmc/glut
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()
}
示例#16
0
func RenderFontAt(text string, x, y float64) {
	gl.PushMatrix()

	gl.RasterPos2d(x, y)

	Font.Render(text)

	gl.PopMatrix()
}
示例#17
0
文件: layout.go 项目: glenn-brown/vu
func (s square) Render(w, h, d float64) {
	gl.PushMatrix()
	dim := w
	if dim > h {
		dim = h
	}
	gl.Translated((w-dim)/2.0, (h-dim)/2.0, 0)
	gl.PopMatrix()
}
示例#18
0
func (self *Console) Draw(t int64) {
	gl.MatrixMode(gl.MODELVIEW)
	gl.PushMatrix()
	gl.LoadIdentity()

	gl.Disable(gl.DEPTH_TEST)
	gl.Disable(gl.LIGHTING)
	gl.Disable(gl.LIGHT0)
	gl.Disable(gl.LIGHT1)

	h := float32(consoleFont.height) * PIXEL_SCALE
	margin := float32(3.0) * PIXEL_SCALE
	consoleHeight := 3 * h

	gl.MatrixMode(gl.MODELVIEW)

	gl.LoadIdentity()
	gl.Color4ub(0, 0, 0, 208)

	gl.Begin(gl.QUADS)
	gl.Vertex2f(float32(viewport.lplane), float32(viewport.bplane)+consoleHeight+margin*2) // Bottom Left Of The Texture and Quad
	gl.Vertex2f(float32(viewport.rplane), float32(viewport.bplane)+consoleHeight+margin*2) // Bottom Right Of The Texture and Quad
	gl.Vertex2f(float32(viewport.rplane), float32(viewport.bplane))                        // Top Right Of The Texture and Quad
	gl.Vertex2f(float32(viewport.lplane), float32(viewport.bplane))                        // Top Left Of The Texture and Quad
	gl.End()

	gl.Translatef(float32(viewport.lplane)+margin, float32(viewport.bplane)+consoleHeight+margin-h, 0)
	consoleFont.Print(fmt.Sprintf("FPS: %5.2f V: %d (%d) CH: %d M: %d", self.fps, self.vertices, self.culledVertices, len(TheWorld.chunks), len(TheWorld.mobs)))
	gl.LoadIdentity()
	gl.Translatef(float32(viewport.lplane)+margin, float32(viewport.bplane)+consoleHeight+margin-2*h, 0)

	consoleFont.Print(fmt.Sprintf("X: %5.2f Y: %4.2f Z: %5.2f H: %5.2f (%s) D: %0.1f (%d)", ThePlayer.position[XAXIS], ThePlayer.position[YAXIS], ThePlayer.position[ZAXIS], ThePlayer.heading, HeadingToCompass(ThePlayer.heading), ThePlayer.distanceTravelled, ThePlayer.distanceFromStart))

	gl.LoadIdentity()
	gl.Translatef(float32(viewport.lplane)+margin, float32(viewport.bplane)+consoleHeight+margin-3*h, 0)

	numgc := uint32(0)
	avggc := float64(0)
	var last3 [3]float64
	if self.mem.NumGC > 3 {
		numgc = self.mem.NumGC
		avggc = float64(self.mem.PauseTotalNs) / float64(self.mem.NumGC) / 1e6
		index := int(numgc) - 1
		if index > 255 {
			index = 255
		}

		last3[0] = float64(self.mem.PauseNs[index]) / 1e6
		last3[1] = float64(self.mem.PauseNs[index-1]) / 1e6
		last3[2] = float64(self.mem.PauseNs[index-2]) / 1e6
	}

	consoleFont.Print(fmt.Sprintf("Mem: %.1f/%.1f   GC: %.1fms [%d: %.1f, %.1f, %.1f] ChGen: %.1fms | Sc: %.1f TOD: %.1f", float64(self.mem.Alloc)/(1024*1024), float64(self.mem.Sys)/(1024*1024), avggc, numgc, last3[0], last3[1], last3[2], float64(self.chunkGenerationTime)/1e6, viewport.scale, timeOfDay))

	gl.PopMatrix()
}
示例#19
0
文件: sdlgears.go 项目: nkostelnik/gl
func draw() {

	gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)

	gl.PushMatrix()
	gl.Rotated(view_rotx, 1.0, 0.0, 0.0)
	gl.Rotated(view_roty, 0.0, 1.0, 0.0)
	gl.Rotated(view_rotz, 0.0, 0.0, 1.0)

	gl.PushMatrix()
	gl.Translated(-3.0, -2.0, 0.0)
	gl.Rotated(angle, 0.0, 0.0, 1.0)
	gl.CallList(gear1)
	gl.PopMatrix()

	gl.PushMatrix()
	gl.Translated(3.1, -2.0, 0.0)
	gl.Rotated(-2.0*angle-9.0, 0.0, 0.0, 1.0)
	gl.CallList(gear2)
	gl.PopMatrix()

	gl.PushMatrix()
	gl.Translated(-3.1, 4.2, 0.0)
	gl.Rotated(-2.0*angle-25.0, 0.0, 0.0, 1.0)
	gl.CallList(gear3)
	gl.PopMatrix()

	gl.PopMatrix()

	sdl.GL_SwapBuffers()

	Frames++
	{
		t := sdl.GetTicks()
		if t-T0 >= 5000 {
			seconds := (t - T0) / 1000.0
			fps := Frames / seconds
			print(Frames, " frames in ", seconds, " seconds = ", fps, " FPS\n")
			T0 = t
			Frames = 0
		}
	}
}
示例#20
0
func draw() {

	gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)

	gl.PushMatrix()
	gl.Rotated(view_rotx, 1.0, 0.0, 0.0)
	gl.Rotated(view_roty, 0.0, 1.0, 0.0)
	gl.Rotated(view_rotz, 0.0, 0.0, 1.0)

	gl.PushMatrix()
	gl.Translated(-3.0, -2.0, 0.0)
	gl.Rotated(angle, 0.0, 0.0, 1.0)
	gl.CallList(gear1)
	gl.PopMatrix()

	gl.PushMatrix()
	gl.Translated(3.1, -2.0, 0.0)
	gl.Rotated(-2.0*angle-9.0, 0.0, 0.0, 1.0)
	gl.CallList(gear2)
	gl.PopMatrix()

	gl.PushMatrix()
	gl.Translated(-3.1, 4.2, 0.0)
	gl.Rotated(-2.0*angle-25.0, 0.0, 0.0, 1.0)
	gl.CallList(gear3)
	gl.PopMatrix()

	gl.PopMatrix()

	glfw.SwapBuffers()

	Frames++
	{
		t := glfw.Time()
		if t-T0 >= 5 {
			seconds := (t - T0)
			fps := float64(Frames) / seconds
			print(Frames, " frames in ", int(seconds), " seconds = ", int(fps), " FPS\n")
			T0 = t
			Frames = 0
		}
	}
}
示例#21
0
文件: layout.go 项目: glenn-brown/vu
func (s stack) Render(w, h, d float64) {
	l := len(s.renderers)
	dw := d / float64(l)
	gl.PushMatrix()
	for _, r := range s.renderers {
		r.Render(w, h, dw)
		gl.Translated(0, 0, dw)
	}
	gl.PopMatrix()
}
示例#22
0
func (m *Model) Render() {
	if globals.UseShader {
		program.SetModelMatrix(m.Mat)
		m.data.Render()
	} else {
		gl.PushMatrix()
		gl.MultMatrixf(m.Mat.Ptr32())
		m.data.Render()
		gl.PopMatrix()
	}
}
示例#23
0
func (t *Nurbs) Render() {
	t.vbo.Enable()
	if globals.UseShader {
		program.SetModelMatrix(mat4.Identity())
		t.vbo.Draw(gl.TRIANGLES)
	} else {
		gl.PushMatrix()
		gl.MultMatrixf(mat4.Identity().Ptr32())
		t.vbo.Draw(gl.TRIANGLES)
		gl.PopMatrix()
	}
	t.vbo.Disable()
}
示例#24
0
func drawCircle(s CircleShape) {
	center := s.Center()
	radius := s.Radius()
	angle := s.Body().Angle()

	gl.VertexPointer(2, 0, circleVerts)
	gl.PushMatrix()
	gl.Translated(center.X, center.Y, 0.0)
	gl.Rotated(angle*180.0/math.Pi, 0.0, 0.0, 1.0)
	gl.Scaled(radius, radius, 1.0)
	gl.DrawArrays(gl.LINE_STRIP, 0, len(circleVerts)/2)
	gl.PopMatrix()
}
示例#25
0
文件: layout.go 项目: glenn-brown/vu
func renderLandscape(r Renderer, w, h, d float64) {
	gl.PushMatrix()
	hh := w / math.Phi
	if hh <= h {
		gl.Translated(0, (h-hh)/2.0, 0)
		r.Render(w, hh, d)
	} else {
		ww := h * math.Phi
		gl.Translated((w-ww)/2.0, 0, 0)
		r.Render(ww, h, d)
	}
	gl.PopMatrix()
}
示例#26
0
文件: layout.go 项目: glenn-brown/vu
func renderPortrait(r Renderer, w, h, d float64) {
	gl.PushMatrix()
	ww := h / math.Phi
	if ww <= w {
		gl.Translated((w-ww)/2.0, 0, 0)
		r.Render(ww, h, d)
	} else {
		hh := w * math.Phi
		gl.Translated(0, (h-hh)/2.0, 0)
		r.Render(w, hh, d)
	}
	gl.PopMatrix()
}
示例#27
0
func (self *Picker) DrawItemHighlight(t int64, position Action) {
	gl.PushMatrix()
	gl.LoadIdentity()

	actionItemAngle := -(float64(position) - 1.5) * math.Pi / 4
	gl.Begin(gl.TRIANGLE_FAN)
	gl.Color4ub(64, 64, 64, 228)
	gl.Vertex2f(self.x-self.actionItemRadius*float32(math.Sin(actionItemAngle)), self.y+self.actionItemRadius*float32(math.Cos(actionItemAngle)))
	for angle := float64(0); angle <= 2*math.Pi; angle += math.Pi / 2 / 10 {
		gl.Vertex2f(self.x-self.actionItemRadius*float32(math.Sin(actionItemAngle))-float32(math.Sin(angle))*self.selectionRadius, self.y+self.actionItemRadius*float32(math.Cos(actionItemAngle))+float32(math.Cos(angle))*self.selectionRadius)
	}
	gl.End()
	gl.PopMatrix()
}
示例#28
0
文件: voronoi.go 项目: glenn-brown/vu
func (v *Voronoi) Render(w, h, d float64) {
	gl.PushMatrix()
	gl.Scaled(w, h, 1)

	rng := rand.New(rand.NewSource(42))
	rng.Seed(42)

	// Draw fill colors

	for _, wall := range v.cellWalls {
		gl.Color3ub(
			uint8(100+rng.Int31n(128)),
			uint8(100+rng.Int31n(128)),
			uint8(100+rng.Int31n(128)))
		gl.Begin(gl.TRIANGLE_FAN)
		for _, p := range wall {
			if p != nil && boundedPoint(p) {
				gl.Vertex2d(p.X, p.Y)
			}
		}
		gl.End()
	}

	// Draw lines

	gl.LineWidth(1.5)
	gl.Color3ub(0, 128, 0)
	gl.Begin(gl.LINES)
	for _, edge := range v.edges {
		if boundedEdge(edge) {
			gl.Vertex2d(edge.Start.X, edge.Start.Y)
			gl.Vertex2d(edge.End.X, edge.End.Y)
		}
	}
	gl.End()

	// Draw points.

	gl.PointSize(2)
	gl.Color3ub(255, 255, 255)
	gl.Begin(gl.POINTS)
	for _, point := range v.points {
		gl.Vertex2d(point.X, point.Y)
	}
	gl.End()
	gl.PopMatrix()
}
示例#29
0
func (self *Inventory) ShowTooltip(x, y float64, str string) {
	h, w := inventoryItemFont.Measure(str)

	pad := 4 * PIXEL_SCALE
	gl.PushMatrix()

	gl.LoadIdentity()
	gl.Color4ub(0, 0, 0, 255)
	gl.Begin(gl.QUADS)
	gl.Vertex2d(x, y)
	gl.Vertex2d(x+w+pad, y)
	gl.Vertex2d(x+w+pad, y+h)
	gl.Vertex2d(x, y+h)
	gl.End()

	gl.Translated(x+pad/2, y+pad/2, 0)
	inventoryItemFont.Print(str)

	gl.PopMatrix()
}
示例#30
0
文件: world.go 项目: glenn-brown/aima
func (world *World) Render(w, h, d float64) {
	gl.PushMatrix()
	gl.Scaled(w, h, d)

	// Draw the goal
	gl.Begin(gl.POINTS)
	gl.Color3ub(255, 0, 0)
	gl.PointSize(6)
	gl.Vertex2d(world.goal.X, world.goal.Y)
	gl.End()

	// Draw the obstacles
	gl.Color4ub(0, 0, 255, 63)
	world.obstacles.Render()

	// Draw the percept
	gl.Color4ub(0, 255, 0, 127)
	gl.LineWidth(1.5)
	gl.Begin(gl.LINES)
	for _, pt := range world.percept {
		gl.Vertex2d(world.robot.X, world.robot.Y)
		gl.Vertex2d(world.robot.X+pt.X, world.robot.Y+pt.Y)
	}
	gl.End()

	// Draw the map
	gl.Color3ub(0, 0, 255)
	gl.LineWidth(2)
	// FIXME

	// Draw the robot
	gl.Color3ub(0, 255, 0)
	gl.PointSize(4)
	gl.Begin(gl.POINTS)
	gl.Vertex2d(world.robot.X, world.robot.Y)
	gl.End()

	gl.PopMatrix()
}