Ejemplo n.º 1
0
func (wp *waypoint) RenderOnFloor() {
	if !wp.active {
		return
	}
	wp.drawn = true
	gl.Color4ub(200, 0, 0, 128)
	base.EnableShader("waypoint")
	base.SetUniformF("waypoint", "radius", float32(wp.Radius))

	t := float32(time.Now().UnixNano()%1e15) / 1.0e9
	base.SetUniformF("waypoint", "time", t)
	gl.Begin(gl.QUADS)
	gl.TexCoord2i(0, 1)
	gl.Vertex2i(int32(wp.X-wp.Radius), int32(wp.Y-wp.Radius))
	gl.TexCoord2i(0, 0)
	gl.Vertex2i(int32(wp.X-wp.Radius), int32(wp.Y+wp.Radius))
	gl.TexCoord2i(1, 0)
	gl.Vertex2i(int32(wp.X+wp.Radius), int32(wp.Y+wp.Radius))
	gl.TexCoord2i(1, 1)
	gl.Vertex2i(int32(wp.X+wp.Radius), int32(wp.Y-wp.Radius))
	gl.End()

	base.EnableShader("")

	// base.EnableShader("")
}
Ejemplo n.º 2
0
func (gw *GameWindow) Draw(region gui.Region, style gui.StyleStack) {
	defer base.StackCatcher()
	defer func() {
		// gl.Translated(gl.Double(gw.region.X), gl.Double(gw.region.Y), 0)
		gl.Disable(gl.TEXTURE_2D)
		gl.Color4ub(255, 255, 255, 255)
		gl.LineWidth(3)
		gl.Begin(gl.LINES)
		bx, by := gl.Int(region.X), gl.Int(region.Y)
		bdx, bdy := gl.Int(region.Dx), gl.Int(region.Dy)
		gl.Vertex2i(bx, by)
		gl.Vertex2i(bx, by+bdy)
		gl.Vertex2i(bx, by+bdy)
		gl.Vertex2i(bx+bdx, by+bdy)
		gl.Vertex2i(bx+bdx, by+bdy)
		gl.Vertex2i(bx+bdx, by)
		gl.Vertex2i(bx+bdx, by)
		gl.Vertex2i(bx, by)
		gl.End()
		gl.LineWidth(1)
	}()

	gw.Engine.Pause()
	game := gw.Engine.GetState().(*Game)
	game.RenderLocal(region, gw.Local)
	gw.Engine.Unpause()
}
Ejemplo n.º 3
0
func Cylinder(r, h gl.Float, slices int, hollow, solid bool) {
	res := 2 * math.Pi / float64(slices)
	mode := gl.LINE_LOOP
	if solid {
		mode = gl.QUADS
	}
	gl.Begin(gl.Enum(mode))
	for a := 0.0; a < 2*math.Pi; a += res {
		gl.Normal3f(gl.Float(math.Cos(a)), gl.Float(math.Sin(a)), 0)
		gl.Vertex3f(r*gl.Float(math.Cos(a)), r*gl.Float(math.Sin(a)), 0)
		gl.Vertex3f(r*gl.Float(math.Cos(a)), r*gl.Float(math.Sin(a)), h)
		a += res
		gl.Vertex3f(r*gl.Float(math.Cos(a)), r*gl.Float(math.Sin(a)), h)
		gl.Vertex3f(r*gl.Float(math.Cos(a)), r*gl.Float(math.Sin(a)), 0)
	}
	gl.End()
	if !hollow {
		// X Y plane
		if h < 0 {
			gl.Normal3f(0, 0, 1)
		} else {
			gl.Normal3f(0, 0, -1)
		}
		Circle(r, slices, solid)
		// Top (or bottom)
		if h < 0 {
			gl.Normal3f(0, 0, -1)
		} else {
			gl.Normal3f(0, 0, 1)
		}
		gl.Translatef(0, 0, h)
		Circle(r, slices, solid)
	}
}
Ejemplo n.º 4
0
func (tsm *ThunderSubMenu) Draw(region Region, style StyleStack) {
	gl.Disable(gl.TEXTURE_2D)
	gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
	gl.Enable(gl.BLEND)
	base.EnableShader("marble")
	offset, ok := style.Get("offset").(linear.Vec2)
	if ok {
		base.SetUniformV2("marble", "offset", offset)
	} else {
		base.SetUniformV2("marble", "offset", linear.Vec2{})
	}
	gl.Color4ub(255, 255, 255, 255)
	gl.Begin(gl.QUADS)
	x := gl.Int(region.X)
	y := gl.Int(region.Y)
	dx := gl.Int(region.Dx)
	dy := gl.Int(region.Dy)
	gl.Vertex2i(x, y)
	gl.Vertex2i(x, y+dy)
	gl.Vertex2i(x+dx, y+dy)
	gl.Vertex2i(x+dx, y)
	gl.End()
	base.EnableShader("")
	for i, option := range tsm.Options {
		region.Dy = tsm.requests[option].Dy
		if i == tsm.selected {
			style.PushStyle(map[string]interface{}{"selected": true})
		} else {
			style.PushStyle(map[string]interface{}{"selected": false})
		}
		option.Draw(region, style)
		style.Pop()
		region.Y += tsm.requests[option].Dy
	}
}
Ejemplo n.º 5
0
func drawScene() {
	gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)

	gl.MatrixMode(gl.MODELVIEW)
	gl.LoadIdentity()
	gl.Rotated(-90, 1, 0, 0)
	//gl.Rotated(90, 0, 0, 1)
	gl.Rotated(gl.Double(-viewAngles[2]), 1, 0, 0)
	gl.Rotated(gl.Double(-viewAngles[0]), 0, 1, 0)
	gl.Rotated(gl.Double(-viewAngles[1]), 0, 0, 1)
	gl.Translated(gl.Double(viewOrg[0]), gl.Double(viewOrg[1]), gl.Double(viewOrg[2]))

	var r, g, b gl.Ubyte

	for i, face := range model.Faces {
		r = gl.Ubyte(i) + 100
		g = gl.Ubyte(i>>1) + 100
		b = gl.Ubyte(i>>2) + 100

		if model.Triangle {
			gl.Begin(gl.TRIANGLES)
		} else {
			gl.Begin(gl.LINES)
		}

		gl.Color4ub(r, g, b, 0xff)
		for _, v := range face.Verts {
			gl.Vertex3d(gl.Double(v.Pos[0]), gl.Double(v.Pos[1]), gl.Double(v.Pos[2]))
		}

		gl.End()
	}
}
Ejemplo n.º 6
0
func (gw *GameWindow) Draw(region g2.Region, style g2.StyleStack) {
	defer base.StackCatcher()
	defer func() {
		// gl.Translated(gl.Double(gw.region.X), gl.Double(gw.region.Y), 0)
		gl.Disable(gl.TEXTURE_2D)
		gl.Color4ub(255, 255, 255, 255)
		gl.LineWidth(3)
		gl.Begin(gl.LINES)
		bx, by := gl.Int(region.X), gl.Int(region.Y)
		bdx, bdy := gl.Int(region.Dx), gl.Int(region.Dy)
		gl.Vertex2i(bx, by)
		gl.Vertex2i(bx, by+bdy)
		gl.Vertex2i(bx, by+bdy)
		gl.Vertex2i(bx+bdx, by+bdy)
		gl.Vertex2i(bx+bdx, by+bdy)
		gl.Vertex2i(bx+bdx, by)
		gl.Vertex2i(bx+bdx, by)
		gl.Vertex2i(bx, by)
		gl.End()
		gl.LineWidth(1)
	}()

	gw.Engine.Pause()
	game := gw.Engine.GetState().(*Game)
	// Note that since we do a READER lock on game.local we cannot do any writes
	// to local data while rendering.
	game.local.RLock()
	game.RenderLocal(region)
	game.local.RUnlock()
	gw.Engine.Unpause()
}
Ejemplo n.º 7
0
func (g *Game) renderLosMask(local *LocalData) {
	ent := g.Ents[local.moba.currentPlayer.gid]
	if ent == nil {
		return
	}
	walls := g.temp.VisibleWallCache[GidInvadersStart].GetWalls(int(ent.Pos().X), int(ent.Pos().Y))
	gl.Disable(gl.TEXTURE_2D)
	gl.Color4ub(0, 0, 0, 255)
	gl.Begin(gl.TRIANGLES)
	for _, wall := range walls {
		if wall.Right(ent.Pos()) {
			continue
		}
		a := wall.P
		b := ent.Pos().Sub(wall.P).Norm().Scale(-10000.0).Add(wall.P)
		mid := wall.P.Add(wall.Q).Scale(0.5)
		c := ent.Pos().Sub(mid).Norm().Scale(-10000.0).Add(mid)
		d := ent.Pos().Sub(wall.Q).Norm().Scale(-10000.0).Add(wall.Q)
		e := wall.Q
		gl.Vertex2d(gl.Double(a.X), gl.Double(a.Y))
		gl.Vertex2d(gl.Double(b.X), gl.Double(b.Y))
		gl.Vertex2d(gl.Double(c.X), gl.Double(c.Y))

		gl.Vertex2d(gl.Double(a.X), gl.Double(a.Y))
		gl.Vertex2d(gl.Double(c.X), gl.Double(c.Y))
		gl.Vertex2d(gl.Double(d.X), gl.Double(d.Y))

		gl.Vertex2d(gl.Double(a.X), gl.Double(a.Y))
		gl.Vertex2d(gl.Double(d.X), gl.Double(d.Y))
		gl.Vertex2d(gl.Double(e.X), gl.Double(e.Y))
	}
	gl.End()
	base.EnableShader("horizon")
	base.SetUniformV2("horizon", "center", ent.Pos())
	base.SetUniformF("horizon", "horizon", LosMaxDist)
	gl.Begin(gl.QUADS)
	dx := gl.Int(g.Levels[GidInvadersStart].Room.Dx)
	dy := gl.Int(g.Levels[GidInvadersStart].Room.Dy)
	gl.Vertex2i(0, 0)
	gl.Vertex2i(dx, 0)
	gl.Vertex2i(dx, dy)
	gl.Vertex2i(0, dy)
	gl.End()
	base.EnableShader("")
}
Ejemplo n.º 8
0
func (p *riftWalkProcess) Draw(gid game.Gid, g *game.Game, side int) {
	player, ok := g.Ents[p.PlayerGid].(*game.PlayerEnt)
	if !ok {
		return
	}
	if side != player.Side() {
		return
	}
	frac := p.Stored.Magnitude() / p.Threshold
	if frac < 1 {
		gl.Color4ub(255, 0, 0, 255)
	} else {
		gl.Color4ub(0, 255, 0, 255)
	}
	base.EnableShader("status_bar")
	var outer float32 = 0.2
	var increase float32 = 0.01
	if frac > 1 {
		frac = 1
	}
	base.SetUniformF("status_bar", "frac", float32(frac))
	base.SetUniformF("status_bar", "inner", outer-increase)
	base.SetUniformF("status_bar", "outer", outer)
	base.SetUniformF("status_bar", "buffer", 0.01)
	texture.Render(player.Pos().X-100, player.Pos().Y-100, 200, 200)
	base.EnableShader("")

	dist, radius := p.GetVals()
	dest := player.Pos().Add((linear.Vec2{dist, 0}).Rotate(player.Angle))
	gl.Disable(gl.TEXTURE_2D)
	gl.Color4d(1, 1, 1, 1)
	gl.Begin(gl.LINES)
	gl.Vertex2d(gl.Double(player.Pos().X), gl.Double(player.Pos().Y))
	gl.Vertex2d(gl.Double(dest.X), gl.Double(dest.Y))
	gl.End()
	n := 20
	gl.Begin(gl.LINES)
	for i := 0; i < n; i++ {
		v1 := dest.Add((linear.Vec2{radius, 0}).Rotate(float64(i) / float64(n) * 2 * math.Pi))
		v2 := dest.Add((linear.Vec2{radius, 0}).Rotate(float64(i+1) / float64(n) * 2 * math.Pi))
		gl.Vertex2d(gl.Double(v1.X), gl.Double(v1.Y))
		gl.Vertex2d(gl.Double(v2.X), gl.Double(v2.Y))
	}
	gl.End()
}
Ejemplo n.º 9
0
func (gw *GameWindow) Draw(region gui.Region) {
	gw.region = region
	latest_region = region
	gl.PushMatrix()
	defer gl.PopMatrix()
	gl.Translated(gl.Double(gw.region.X), gl.Double(gw.region.Y), 0)

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

	gw.game.manaSource.Draw(gw, float64(gw.game.Dx), float64(gw.game.Dy))

	gl.Begin(gl.LINES)
	gl.Color4d(1, 1, 1, 1)
	for _, poly := range gw.game.Room.Walls {
		for i := range poly {
			seg := poly.Seg(i)
			gl.Vertex2d(gl.Double(seg.P.X), gl.Double(seg.P.Y))
			gl.Vertex2d(gl.Double(seg.Q.X), gl.Double(seg.Q.Y))
		}
	}
	gl.End()

	gl.Begin(gl.TRIANGLE_FAN)
	gl.Color4d(1, 0, 0, 1)
	for _, poly := range gw.game.Room.Lava {
		for _, v := range poly {
			gl.Vertex2d(gl.Double(v.X), gl.Double(v.Y))
		}
	}
	gl.End()

	gl.Color4d(1, 1, 1, 1)
	for _, ent := range gw.game.Ents {
		ent.Draw(gw.game)
	}
	gl.Disable(gl.TEXTURE_2D)

	for _, player := range local.players {
		if player.active_ability != nil {
			player.active_ability.Draw(player.id, gw.game)
		}
	}
	// base.GetDictionary("luxisr").RenderString("monkeys!!!", 10, 10, 0, float64(gw.game.Game_thinks), gin.Left)
}
Ejemplo n.º 10
0
func (s *SegDisplay) lowerMid() {
	gl.Begin(gl.POLYGON)
	gl.Vertex2d(-s.mW*0.1, -s.mH*0.8)
	gl.Vertex2d(+s.mW*0.0, -s.mH*0.9)
	gl.Vertex2d(+s.mW*0.1, -s.mH*0.8)
	gl.Vertex2d(+s.mW*0.1, -s.mH*0.1)
	gl.Vertex2d(+s.mW*0.0, -s.mH*0.0)
	gl.Vertex2d(-s.mW*0.1, -s.mH*0.1)
	gl.End()
}
Ejemplo n.º 11
0
func (sp *SpawnPoint) Render(pos mathgl.Vec2, width float32) {
	gl.Disable(gl.TEXTURE_2D)
	gl.Color4d(1, 1, 1, 0.1)
	gl.Begin(gl.QUADS)
	gl.Vertex2f(pos.X-width/2, pos.Y)
	gl.Vertex2f(pos.X-width/2, pos.Y+width)
	gl.Vertex2f(pos.X+width/2, pos.Y+width)
	gl.Vertex2f(pos.X+width/2, pos.Y)
	gl.End()
}
Ejemplo n.º 12
0
func Render() {
	UpdateViewpos()
	ClearScene()
	gl.Begin(gl.QUADS)
	for i := range polys {
		polys[i].Render()
	}
	gl.End()
	glfw.SwapBuffers()
}
Ejemplo n.º 13
0
func (s *SegDisplay) top() {
	gl.Begin(gl.POLYGON)
	gl.Vertex2d(-s.mW*0.8, +s.mH*0.8)
	gl.Vertex2d(-s.mW*0.9, +s.mH*0.9)
	gl.Vertex2d(-s.mW*0.8, +s.mH*1.0)
	gl.Vertex2d(+s.mW*0.8, +s.mH*1.0)
	gl.Vertex2d(+s.mW*0.9, +s.mH*0.9)
	gl.Vertex2d(+s.mW*0.8, +s.mH*0.8)
	gl.End()
}
Ejemplo n.º 14
0
func (s *SegDisplay) lowerRight() {
	gl.Begin(gl.POLYGON)
	gl.Vertex2d(+s.mW*1.0, -s.mH*0.8)
	gl.Vertex2d(+s.mW*0.9, -s.mH*0.9)
	gl.Vertex2d(+s.mW*0.8, -s.mH*0.8)
	gl.Vertex2d(+s.mW*0.8, -s.mH*0.1)
	gl.Vertex2d(+s.mW*0.9, -s.mH*0.0)
	gl.Vertex2d(+s.mW*1.0, -s.mH*0.1)
	gl.End()
}
Ejemplo n.º 15
0
func (s *SegDisplay) midRight() {
	gl.Begin(gl.POLYGON)
	gl.Vertex2d(+s.mW*0.1, -s.mH*0.1)
	gl.Vertex2d(+s.mW*0.0, +s.mH*0.0)
	gl.Vertex2d(+s.mW*0.1, +s.mH*0.1)
	gl.Vertex2d(+s.mW*0.8, +s.mH*0.1)
	gl.Vertex2d(+s.mW*0.9, +s.mH*0.0)
	gl.Vertex2d(+s.mW*0.8, -s.mH*0.1)
	gl.End()
}
Ejemplo n.º 16
0
func (s *SegDisplay) upperMidRight() {
	gl.Begin(gl.POLYGON)
	gl.Vertex2d(+s.mW*0.8, +s.mH*0.1)
	gl.Vertex2d(+s.mW*0.9, +s.mH*0.1)
	gl.Vertex2d(+s.mW*0.9, +s.mH*0.2)
	gl.Vertex2d(+s.mW*0.1, +s.mH*0.9)
	gl.Vertex2d(+s.mW*0.0, +s.mH*0.9)
	gl.Vertex2d(+s.mW*0.0, +s.mH*0.8)
	gl.End()
}
Ejemplo n.º 17
0
func (s *SegDisplay) upperLeft() {
	gl.Begin(gl.POLYGON)
	gl.Vertex2d(-s.mW*1.0, +s.mH*0.8)
	gl.Vertex2d(-s.mW*0.9, +s.mH*0.9)
	gl.Vertex2d(-s.mW*0.8, +s.mH*0.8)
	gl.Vertex2d(-s.mW*0.8, +s.mH*0.1)
	gl.Vertex2d(-s.mW*0.9, +s.mH*0.0)
	gl.Vertex2d(-s.mW*1.0, +s.mH*0.1)
	gl.End()
}
Ejemplo n.º 18
0
func (co *colorOption) DrawInfo(x, y, dx, dy int) {
	gl.Disable(gl.TEXTURE_2D)
	gl.Color4ub(co.r, co.g, co.b, co.a)
	gl.Begin(gl.QUADS)
	gl.Vertex2i(int32(x), int32(y))
	gl.Vertex2i(int32(x), int32(y+dy))
	gl.Vertex2i(int32(x+dx), int32(y+dy))
	gl.Vertex2i(int32(x+dx), int32(y))
	gl.End()
}
Ejemplo n.º 19
0
func Triangle(one, two, three Point, solid bool) {
	mode := gl.LINE_LOOP
	if solid {
		mode = gl.TRIANGLES
	}
	gl.Begin(gl.Enum(mode))
	gl.Vertex3f(one.X, one.Y, one.Z)
	gl.Vertex3f(two.X, two.Y, two.Z)
	gl.Vertex3f(three.X, three.Y, three.Z)
	gl.End()
}
Ejemplo n.º 20
0
func (editor *editorData) renderPlaceBlock(g *Game) {
	var expandedPoly linear.Poly
	expandPoly(editor.getPoly(g), &expandedPoly)
	gl.Disable(gl.TEXTURE_2D)
	gl.Color4d(1, 1, 1, 1)
	gl.Begin(gl.TRIANGLE_FAN)
	for _, v := range expandedPoly {
		gl.Vertex2d(gl.Double(v.X), gl.Double(v.Y))
	}
	gl.End()
}
Ejemplo n.º 21
0
func (editor *editorData) renderPathing(room *Room, pathing *PathingData) {
	if !editor.pathing.on {
		return
	}
	gl.Disable(gl.TEXTURE_2D)
	gl.Color4ub(255, 255, 255, 255)
	gl.Begin(gl.LINES)
	for x := 0; x <= room.Dx; x += pathingDataGrid {
		gl.Vertex2d(gl.Double(x), 0)
		gl.Vertex2d(gl.Double(x), gl.Double(room.Dy))
	}
	for y := 0; y <= room.Dy; y += pathingDataGrid {
		gl.Vertex2d(0, gl.Double(y))
		gl.Vertex2d(gl.Double(room.Dx), gl.Double(y))
	}
	gl.End()
	dst := editor.cursorPosInGameCoords(room)

	tri := [3]linear.Vec2{
		(linear.Vec2{0.6, 0}).Scale(pathingDataGrid / 2),
		(linear.Vec2{-0.2, 0.2}).Scale(pathingDataGrid / 2),
		(linear.Vec2{-0.2, -0.2}).Scale(pathingDataGrid / 2),
	}

	gl.Begin(gl.TRIANGLES)
	for x := 0; x < room.Dx; x += pathingDataGrid {
		for y := 0; y < room.Dy; y += pathingDataGrid {
			src := linear.Vec2{
				float64(x) + pathingDataGrid/2.0,
				float64(y) + pathingDataGrid/2.0,
			}
			angle := pathing.Dir(src, dst).Angle()
			for _, v := range tri {
				p := v.Rotate(angle).Add(src)
				gl.Vertex2d(gl.Double(p.X), gl.Double(p.Y))
			}
		}
	}
	gl.End()
	// pathing.Dir(src, dst)
}
Ejemplo n.º 22
0
func drawGrid() {
	gl.Color4f(0.2, 0.2, 0.2, 1)
	gl.Begin(gl.LINES)
	for i := -0.5; i < Width; i += 1 {
		gl.Vertex2f(gl.Float(-0.5), gl.Float(i))
		gl.Vertex2f(gl.Float(life.Size), gl.Float(i))

		gl.Vertex2f(gl.Float(i), -0.5)
		gl.Vertex2f(gl.Float(i), gl.Float(life.Size))
	}
	gl.End()
}
Ejemplo n.º 23
0
func Rectangle(one, two Point, solid bool) {
	mode := gl.LINE_LOOP
	if solid {
		mode = gl.QUADS
	}
	gl.Begin(gl.Enum(mode))          // Clockwise from top right
	gl.Vertex3f(one.X, one.Y, one.Z) // Q1
	gl.Vertex3f(one.X, two.Y, one.Z) // Q4
	gl.Vertex3f(two.X, two.Y, two.Z) // Q3
	gl.Vertex3f(two.X, one.Y, two.Z) // Q2
	gl.End()
}
Ejemplo n.º 24
0
func Ellipse(rX, rY gl.Float, slices int, solid bool) {
	mode := gl.LINE_LOOP
	if solid {
		mode = gl.POLYGON
	}
	res := 2 * math.Pi / float64(slices)
	gl.Begin(gl.Enum(mode))
	gl.Vertex2f(0, 0)
	for a := 0.0; a < 2*math.Pi; a += res {
		gl.Vertex2f(rX*gl.Float(math.Cos(a)), rY*gl.Float(math.Sin(a)))
	}
	gl.End()
}
Ejemplo n.º 25
0
func (f *lightning) Draw(ent game.Ent, g *game.Game) {
	if !f.draw {
		return
	}
	gl.Disable(gl.TEXTURE_2D)
	gl.Color4ub(255, 255, 255, 255)
	forward := (linear.Vec2{1, 0}).Rotate(ent.Angle()).Scale(100000.0)
	gl.Begin(gl.LINES)
	v := ent.Pos().Add(forward)
	gl.Vertex2d(gl.Double(v.X), gl.Double(v.Y))
	v = ent.Pos().Sub(forward)
	gl.Vertex2d(gl.Double(v.X), gl.Double(v.Y))
	gl.End()
}
Ejemplo n.º 26
0
func (sb *spriteBox) Draw(region gui.Region) {
	gl.Disable(gl.TEXTURE_2D)
	gl.Color4d(sb.r, sb.g, sb.b, 1)
	gl.Begin(gl.QUADS)
	gl.Vertex2i(int32(region.X+region.Dx/3), int32(region.Y))
	gl.Vertex2i(int32(region.X+region.Dx/3), int32(region.Y+region.Dy))
	gl.Vertex2i(int32(region.X+region.Dx/3*2), int32(region.Y+region.Dy))
	gl.Vertex2i(int32(region.X+region.Dx/3*2), int32(region.Y))
	gl.End()
	if sb.s != nil {
		gl.Enable(gl.TEXTURE_2D)
		tx, ty, tx2, ty2 := sb.s.Bind()
		// fmt.Printf("Tex: %f %f %f %f\n", tx, ty, tx2, ty2)
		gl.Enable(gl.BLEND)
		gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
		gl.Color4f(1, 1, 1, 1)
		gl.Begin(gl.QUADS)
		x := int32(region.X + region.Dx/2)
		y := int32(region.Y + region.Dy/2)
		gl.TexCoord2d(tx, -ty)
		gl.Vertex2i(x-50, y-75)
		gl.TexCoord2d(tx, -ty2)
		gl.Vertex2i(x-50, y+75)
		gl.TexCoord2d(tx2, -ty2)
		gl.Vertex2i(x+50, y+75)
		gl.TexCoord2d(tx2, -ty)
		gl.Vertex2i(x+50, y-75)
		gl.End()
		gl.Color4d(1, 1, 1, 1)
		text := fmt.Sprintf("%d : %s : %s", sb.s.Facing(), sb.s.Anim(), sb.s.AnimState())
		if sb.top {
			dict.RenderString(text, float64(region.X), float64(region.Y+region.Dy)-dict.MaxHeight(), 0, dict.MaxHeight(), gui.Left)
		} else {
			dict.RenderString(text, float64(region.X), float64(region.Y), 0, dict.MaxHeight(), gui.Left)
		}
	}
}
Ejemplo n.º 27
0
func Box(x, y, z float32, solid bool) {
	mode := gl.LINE_LOOP
	if solid {
		mode = gl.QUADS
	}
	X := gl.Float(x) / 2
	Y := gl.Float(y) / 2
	Z := gl.Float(z) / 2
	gl.Begin(gl.Enum(mode))

	gl.Normal3f(0, 0, 1) // Positive Z Face
	gl.Vertex3f(-X, -Y, Z)
	gl.Vertex3f(X, -Y, Z)
	gl.Vertex3f(X, Y, Z)
	gl.Vertex3f(-X, Y, Z)

	gl.Normal3f(0, 0, -1) // Negative Z Face
	gl.Vertex3f(-X, -Y, -Z)
	gl.Vertex3f(-X, Y, -Z)
	gl.Vertex3f(X, Y, -Z)
	gl.Vertex3f(X, -Y, -Z)

	gl.Normal3f(0, 1, 0) // Positive Y Face
	gl.Vertex3f(-X, Y, -Z)
	gl.Vertex3f(-X, Y, Z)
	gl.Vertex3f(X, Y, Z)
	gl.Vertex3f(X, Y, -Z)

	gl.Normal3f(0, -1, 0) // Negative Y Face
	gl.Vertex3f(-X, -Y, -Z)
	gl.Vertex3f(X, -Y, -Z)
	gl.Vertex3f(X, -Y, Z)
	gl.Vertex3f(-X, -Y, Z)

	gl.Normal3f(1, 0, 0) // Positive X Face
	gl.Vertex3f(X, -Y, -Z)
	gl.Vertex3f(X, Y, -Z)
	gl.Vertex3f(X, Y, Z)
	gl.Vertex3f(X, -Y, Z)

	gl.Normal3f(-1, 0, 0) // Negative X Face
	gl.Vertex3f(-X, -Y, -Z)
	gl.Vertex3f(-X, -Y, Z)
	gl.Vertex3f(-X, Y, Z)
	gl.Vertex3f(-X, Y, -Z)

	gl.End()
}
Ejemplo n.º 28
0
func (o *Overlay) Draw(region gui.Region) {
	o.region = region
	switch o.game.Side {
	case SideHaunt:
		if o.game.los.denizens.mode == LosModeBlind {
			return
		}
	case SideExplorers:
		if o.game.los.intruders.mode == LosModeBlind {
			return
		}
	default:
		return
	}
	for _, wp := range o.game.Waypoints {
		if !wp.active || wp.drawn {
			continue
		}

		cx := float32(wp.X)
		cy := float32(wp.Y)
		r := float32(wp.Radius)
		cx1, cy1 := o.game.viewer.BoardToWindow(cx-r, cy-r)
		cx2, cy2 := o.game.viewer.BoardToWindow(cx-r, cy+r)
		cx3, cy3 := o.game.viewer.BoardToWindow(cx+r, cy+r)
		cx4, cy4 := o.game.viewer.BoardToWindow(cx+r, cy-r)
		gl.Color4ub(200, 0, 0, 128)

		base.EnableShader("waypoint")
		base.SetUniformF("waypoint", "radius", float32(wp.Radius))

		t := float32(time.Now().UnixNano()%1e15) / 1.0e9
		base.SetUniformF("waypoint", "time", t)

		gl.Begin(gl.QUADS)
		gl.TexCoord2i(0, 1)
		gl.Vertex2i(int32(cx1), int32(cy1))
		gl.TexCoord2i(0, 0)
		gl.Vertex2i(int32(cx2), int32(cy2))
		gl.TexCoord2i(1, 0)
		gl.Vertex2i(int32(cx3), int32(cy3))
		gl.TexCoord2i(1, 1)
		gl.Vertex2i(int32(cx4), int32(cy4))
		gl.End()

		base.EnableShader("")
	}
}
Ejemplo n.º 29
0
func (c *Console) DrawFocused(region gui.Region) {
	gl.Color4d(0.2, 0, 0.3, 0.8)
	gl.Disable(gl.TEXTURE_2D)
	gl.Begin(gl.QUADS)
	{
		x := gl.Int(region.X)
		y := gl.Int(region.Y)
		x2 := gl.Int(region.X + region.Dx)
		y2 := gl.Int(region.Y + region.Dy)
		gl.Vertex2i(x, y)
		gl.Vertex2i(x, y2)
		gl.Vertex2i(x2, y2)
		gl.Vertex2i(x2, y)
	}
	gl.End()
	gl.Color4d(1, 1, 1, 1)
	y := float64(region.Y) + float64(len(c.lines))*lineHeight
	do_color := func(line string) {
		if strings.HasPrefix(line, "LOG") {
			gl.Color4d(1, 1, 1, 1)
		}
		if strings.HasPrefix(line, "WARN") {
			gl.Color4d(1, 1, 0, 1)
		}
		if strings.HasPrefix(line, "ERROR") {
			gl.Color4d(1, 0, 0, 1)
		}
	}
	if c.start > c.end {
		for i := c.start; i < len(c.lines); i++ {
			do_color(c.lines[i])
			c.dict.RenderString(c.lines[i], c.xscroll, y, 0, lineHeight, gui.Left)
			y -= lineHeight
		}
		for i := 0; i < c.end; i++ {
			do_color(c.lines[i])
			c.dict.RenderString(c.lines[i], c.xscroll, y, 0, lineHeight, gui.Left)
			y -= lineHeight
		}
	} else {
		for i := c.start; i < c.end && i < len(c.lines); i++ {
			do_color(c.lines[i])
			c.dict.RenderString(c.lines[i], c.xscroll, y, 0, lineHeight, gui.Left)
			y -= lineHeight
		}
	}
}
Ejemplo n.º 30
0
func (p *PosWidget) Draw(region Region, style StyleStack) {
	gl.Disable(gl.TEXTURE_2D)
	gl.Color4ub(0, 255, 0, 255)
	gl.Begin(gl.QUADS)
	x := gl.Int(region.X)
	y := gl.Int(region.Y)
	dx := gl.Int(base.GetDictionary("luxisr").StringWidth(p.text, float64(p.Size)))
	dy := gl.Int(p.Size)
	gl.Vertex2i(x, y)
	gl.Vertex2i(x, y+dy)
	gl.Vertex2i(x+dx, y+dy)
	gl.Vertex2i(x+dx, y)
	gl.End()
	base.Log().Printf("%v %v %v %v", x, y, dx, dy)
	gl.Color4ub(255, 0, 255, 255)
	base.GetDictionary("luxisr").RenderString(p.text, float64(region.X), float64(region.Y), 0, float64(p.Size), gui.Left)
}