Example #1
0
func (f frame) Render(w, h, d float64) {
	// Draw a wireframe around the arena
	gl.Color4ub(255, 255, 255, 31)
	gl.LineWidth(2.0)
	gl.Begin(gl.LINE_STRIP)
	gl.Vertex3d(0, 0, 0)
	gl.Vertex3d(w, 0, 0)
	gl.Vertex3d(w, h, 0)
	gl.Vertex3d(0, h, 0)
	gl.Vertex3d(0, 0, 0)
	gl.Vertex3d(0, 0, d)
	gl.Vertex3d(0, h, d)
	gl.Vertex3d(w, h, d)
	gl.Vertex3d(w, 0, d)
	gl.Vertex3d(0, 0, d)
	gl.End()
	gl.Begin(gl.LINES)
	gl.Vertex3d(0, h, 0)
	gl.Vertex3d(0, h, d)
	gl.Vertex3d(w, 0, 0)
	gl.Vertex3d(w, 0, d)
	gl.Vertex3d(w, h, 0)
	gl.Vertex3d(w, h, d)
	gl.End()

	// Render the page.
	if f.renderer != nil {
		f.renderer.Render(w, h, d)
	}
}
Example #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()
}
Example #3
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()
}
Example #4
0
File: main.go Project: sycoso/glfw
func drawScene() {
	gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)

	gl.LoadIdentity()
	gl.Translatef(-1.5, 0, -6)
	gl.Rotatef(trisAngle, 0, 1, 0)

	gl.Begin(gl.TRIANGLES)
	gl.Color3f(1, 0, 0)
	gl.Vertex3f(0, 1, 0)
	gl.Color3f(0, 1, 0)
	gl.Vertex3f(-1, -1, 0)
	gl.Color3f(0, 0, 1)
	gl.Vertex3f(1, -1, 0)
	gl.End()

	gl.LoadIdentity()
	gl.Translatef(1.5, 0, -6)
	gl.Rotatef(quadAngle, 1, 0, 0)
	gl.Color3f(0.5, 0.5, 1.0)

	gl.Begin(gl.QUADS)
	gl.Vertex3f(-1, 1, 0)
	gl.Vertex3f(1, 1, 0)
	gl.Vertex3f(1, -1, 0)
	gl.Vertex3f(-1, -1, 0)
	gl.End()

	trisAngle += 0.2
	quadAngle -= 0.15

	glfw.SwapBuffers()
}
Example #5
0
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)
}
Example #6
0
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)
	}
}
Example #7
0
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)
	}
}
// Here goes our drawing code
func drawGLScene() {
	// Clear the screen and depth buffer
	gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)

	// Move left 1.5 units and into the screen 6.0 units.
	gl.LoadIdentity()
	gl.Translatef(-1.5, 0.0, -6.0)
	gl.Rotatef(float32(rtri), 0.0, 1.0, 0.0) // Rotate the triangle on the Y axis

	gl.Begin(gl.TRIANGLES)       // Draw triangles
	gl.Color3f(1.0, 0.0, 0.0)    // Set The Color To Red
	gl.Vertex3f(0.0, 1.0, 0.0)   // top
	gl.Color3f(0.0, 1.0, 0.0)    // Set The Color To Red
	gl.Vertex3f(-1.0, -1.0, 0.0) // bottom left
	gl.Color3f(0.0, 0.0, 1.0)    // Set The Color To Red
	gl.Vertex3f(1.0, -1.0, 0.0)  // bottom right
	gl.End()                     // finish drawing the triangle

	// Move right 3 units
	gl.LoadIdentity()
	gl.Translatef(1.5, 0.0, -6.0)
	gl.Color3f(0.5, 0.5, 1.0)                 // Set The Color To Blue One Time Only
	gl.Rotatef(float32(rquad), 1.0, 0.0, 0.0) // rotate the quad on the X axis

	gl.Begin(gl.QUADS)           // draw quads
	gl.Vertex3f(-1.0, 1.0, 0.0)  // top left
	gl.Vertex3f(1.0, 1.0, 0.0)   // top right
	gl.Vertex3f(1.0, -1.0, 0.0)  // bottom right
	gl.Vertex3f(-1.0, -1.0, 0.0) // bottom left
	gl.End()                     // done drawing the quad

	// Draw to the screen
	sdl.GL_SwapBuffers()

	rtri += 0.2   // Increase The Rotation Variable For The Triangle
	rquad -= 0.15 // Decrease The Rotation Variable For The Quad

	// Gather our frames per second
	frames++
	t := sdl.GetTicks()
	if t-t0 >= 5000 {
		seconds := (t - t0) / 1000.0
		fps := frames / seconds
		fmt.Println(frames, "frames in", seconds, "seconds =", fps, "FPS")
		t0 = t
		frames = 0
	}
}
Example #9
0
func (pen *Pen) lineTo(p Point) {

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

	gl.Color4f(0.0, 0.0, 0.0, 0.1)

	gl.Begin(gl.LINES)

	for _, s := range pen.points {

		if s.x == 0 && s.y == 0 {
			continue
		}

		if p.distanceTo(s) < 20.0 {

			gl.Vertex2i(int(p.x), int(p.y))
			gl.Vertex2i(int(s.x), int(s.y))

		}

	}

	gl.End()

	pen.n = (pen.n + 1) % len(pen.points)
	pen.points[pen.n] = p

	pen.moveTo(p)

}
Example #10
0
func (s *Sprite) Draw(x, y, angle, scale float32, blend bool) {
	gl.Enable(gl.TEXTURE_2D)
	gl.Disable(gl.COLOR_MATERIAL)
	if blend {
		gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
		gl.Enable(gl.BLEND)
	} else {
		gl.Disable(gl.BLEND)
		gl.BlendFunc(gl.ONE, gl.ZERO)
	}

	gl.MatrixMode(gl.MODELVIEW)
	gl.LoadIdentity()
	gl.Translatef(x, y, 0)
	gl.Rotatef(angle*360/(2*math.Pi), 0, 0, 1)
	gl.Scalef(scale, scale, 1)
	s.tex.Bind(gl.TEXTURE_2D)
	gl.Begin(gl.QUADS)
	gl.Color3f(1, 1, 1)
	gl.TexCoord2d(0, 0)
	gl.Vertex3f(-0.5*s.width, -0.5*s.height, 0)
	gl.TexCoord2d(1, 0)
	gl.Vertex3f(0.5*s.width, -0.5*s.height, 0)
	gl.TexCoord2d(1, 1)
	gl.Vertex3f(0.5*s.width, 0.5*s.height, 0)
	gl.TexCoord2d(0, 1)
	gl.Vertex3f(-0.5*s.width, 0.5*s.height, 0)
	gl.End()
	gl.Disable(gl.TEXTURE_2D)
	gl.Disable(gl.BLEND)
}
Example #11
0
File: main.go Project: sycoso/glfw
func (pen *Pen) lineTo(x, y int) {
	gl.Enable(gl.BLEND)
	gl.Enable(gl.POINT_SMOOTH)
	gl.Enable(gl.LINE_SMOOTH)
	gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
	gl.Color4f(0.0, 0.0, 0.0, 0.1)
	gl.Begin(gl.LINES)

	var p [2]int
	for i := range pen.points {
		p = pen.points[i]
		if p[0] == 0 && p[1] == 0 {
			continue
		}

		if distanceTo(x, y, p[0], p[1]) < 10.0 {
			gl.Vertex2i(x, y)
			gl.Vertex2i(p[0], p[1])
		}
	}

	gl.End()

	pen.n = (pen.n + 1) % len(pen.points)
	pen.points[pen.n][0] = x
	pen.points[pen.n][1] = y
	pen.moveTo(x, y)
}
Example #12
0
func drawLine(x1, y1, x2, y2 float64) {

	gl.Begin(gl.LINES)
	gl.Vertex2d(x1, y1)
	gl.Vertex2d(x2, y2)
	gl.End()
}
Example #13
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()

}
Example #14
0
func (pp Points) Render() {
	gl.Begin(gl.POINTS)
	for _, p := range pp {
		gl.Vertex2d(p.X, p.Y)
	}
	gl.End()
}
Example #15
0
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)
}
Example #16
0
func drawCircle(x, y, r float64) {

	//@TODO: Should speed this up by pre-computing all these cos() and sin() calculations and storing in a lookup table.
	gl.Begin(gl.TRIANGLE_FAN)
	//		gl.Color3d(me.red, me.green, me.blue)

	gl.Vertex2d(x, y)

	pi2 := 2 * math.Pi

	num := 36
	dTheta := pi2 / float64(num)
	theta := float64(0)
	for i := 0; i < num; i++ {

		theta += dTheta

		dx := math.Cos(theta) * r
		dy := math.Sin(theta) * r

		gl.Vertex2d(x+dx, y+dy)
	}

	theta += dTheta

	dx := math.Cos(theta) * r
	dy := math.Sin(theta) * r

	gl.Vertex2d(x+dx, y+dy)

	gl.End()
}
Example #17
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()

}
Example #18
0
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()
}
Example #19
0
// Render the mesh
// The V array must be a multiple of 3 since it uses triangles to render the mesh.
// If two or more triangles share the same edge the user can pass the same pointer twice
func (m *Mesh) Render() {
	count := 0
	gl.Begin(gl.TRIANGLES)
	for _, v := range m.V {
		if count%3 == 0 && count > 0 {
			gl.End()
			gl.Begin(gl.TRIANGLES)
			count = 0
		}
		gl.Color3f(1, 0, 0)
		gl.Vertex3f(v.X, v.Y, v.Z)
		count++
	}
	if count > 0 {
		gl.End()
	}
}
Example #20
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()
}
Example #21
0
// Draw unit vectors at the origin.
// The X vector is red, Y is green, and Z is blue.
func drawOrigin() {
	gl.Color3ub(0xff, 0, 0)
	gl.Begin(gl.LINES)
	gl.Vertex3d(0, 0, 0)
	gl.Vertex3d(1, 0, 0)
	gl.End()

	gl.Color3ub(0, 0xff, 0)
	gl.Begin(gl.LINES)
	gl.Vertex3d(0, 0, 0)
	gl.Vertex3d(0, 1, 0)
	gl.End()

	gl.Color3ub(0, 0, 0xff)
	gl.Begin(gl.LINES)
	gl.Vertex3d(0, 0, 0)
	gl.Vertex3d(0, 0, 1)
	gl.End()
}
Example #22
0
func drawBullets() {
	gl.Begin(gl.POINTS)
	gl.Color3f(1.0, 0.0, 1.0)
	for i := 0; i < MAX_BULLETS; i++ {
		if bullet[i].inuse {
			gl.Vertex2f(bullet[i].x, bullet[i].y)
		}
	}
	gl.End()
}
Example #23
0
func display() {
	gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)

	positionCamera()

	gl.Begin(gl.QUADS)
	drawTerrain()
	gl.End()

	gl.Flush()
}
Example #24
0
func (poly Polygon) Render() {
	modes := [3]gl.GLenum{gl.LINE_LOOP, gl.POLYGON, gl.POINTS}
	for i := range modes {
		gl.Begin(modes[i])
		last := len(poly) - 1
		for i := range poly {
			pt := poly[last-i]
			gl.Vertex2d(pt.X, pt.Y)
		}
		gl.End()
	}
}
Example #25
0
File: simple.go Project: tmc/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. */
}
Example #26
0
func (t *Skybox) RenderScaled(center, scale *Vec3) {
	v := []*Vec3{
		V3(-1, -1, 1),
		V3(1, -1, 1),
		V3(1, 1, 1),
		V3(-1, 1, 1),
		V3(-1, -1, -1),
		V3(1, -1, -1),
		V3(1, 1, -1),
		V3(-1, 1, -1)}
	for i := 0; i < 8; i++ {
		v[i].Muli(scale).Addi(center)
	}

	if globals.UseShader {
		program.Unuse()
	}

	//*//save attributes and change them
	gl.PushAttrib(gl.ENABLE_BIT | gl.TEXTURE_BIT)
	defer gl.PopAttrib() //reset to old attributes
	gl.Enable(gl.TEXTURE_2D)
	gl.Disable(gl.DEPTH_TEST)
	gl.Disable(gl.LIGHTING)
	gl.Disable(gl.BLEND) //*/
	oneSide := func(tex *texture.Texture, a, b, c, d int, n *Vec3) {
		tex.BindForSkybox(color.White)
		gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE)
		gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE)
		gl.Begin(gl.TRIANGLES)
		gl.Normal3dv(n.Slc())
		gl.TexCoord2i(0, 0)
		gl.Vertex3dv(v[a].Slc())
		gl.TexCoord2i(1, 0)
		gl.Vertex3dv(v[b].Slc())
		gl.TexCoord2i(1, 1)
		gl.Vertex3dv(v[c].Slc())
		gl.TexCoord2i(0, 0)
		gl.Vertex3dv(v[a].Slc())
		gl.TexCoord2i(1, 1)
		gl.Vertex3dv(v[c].Slc())
		gl.TexCoord2i(0, 1)
		gl.Vertex3dv(v[d].Slc())
		gl.End()
	}
	oneSide(t.up, 2, 3, 7, 6, V3(0, -1, 0))
	oneSide(t.dn, 5, 4, 0, 1, V3(0, 1, 0))
	oneSide(t.lt, 5, 1, 2, 6, V3(1, 0, 0))
	oneSide(t.rt, 0, 4, 7, 3, V3(-1, 0, 0))
	oneSide(t.ft, 1, 0, 3, 2, V3(0, 0, -1))
	oneSide(t.bk, 4, 5, 6, 7, V3(0, 0, 1))
}
Example #27
0
func (this *Cursor) Draw(w, h Double, col *color24.Color24) {
	var p = this.Pos.Mul(V2(w, h))
	var a = p.Add(V2(-10, -10))
	var b = p.Add(V2(10, -10))
	gl.Disable(gl.TEXTURE_2D)
	col.Gl()
	gl.Begin(gl.TRIANGLES)
	p.Gl()
	a.Gl()
	b.Gl()
	gl.End()
	gl.Enable(gl.TEXTURE_2D)
}
Example #28
0
func drawSquare(x, y, length float64) {

	x2 := x + length
	y2 := y + length

	gl.Begin(gl.QUADS)
	gl.Color3d(0.75, 0.35, 0.35)
	gl.Vertex2d(x, y)
	gl.Vertex2d(x2, y)
	gl.Vertex2d(x2, y2)
	gl.Vertex2d(x, y2)
	gl.End()
}
Example #29
0
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()
}
Example #30
0
func drawTexRect(tex *texture.Texture, a, b *Vec2) {
	tex.Bind()
	gl.Begin(gl.QUADS)
	gl.TexCoord2i(0, 0)
	a.Gl()
	gl.TexCoord2i(1, 0)
	V2(b.X, a.Y).Gl()
	gl.TexCoord2i(1, 1)
	b.Gl()
	gl.TexCoord2i(0, 1)
	V2(a.X, b.Y).Gl()
	gl.End()
}