当前位置: 首页>>代码示例>>Golang>>正文


Golang gl21.Vertex2d函数代码示例

本文整理汇总了Golang中github.com/chsc/gogl/gl21.Vertex2d函数的典型用法代码示例。如果您正苦于以下问题:Golang Vertex2d函数的具体用法?Golang Vertex2d怎么用?Golang Vertex2d使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Vertex2d函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: Draw

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()
}
开发者ID:runningwild,项目名称:jota,代码行数:14,代码来源:ability_graphics.go

示例2: Draw

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()
}
开发者ID:runningwild,项目名称:magnus,代码行数:45,代码来源:rift_walk.go

示例3: Draw

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)
}
开发者ID:dgthunder,项目名称:magnus,代码行数:45,代码来源:game.go

示例4: Render

func (l *Los) Render() {
	var v0, v1 linear.Vec2
	gl.Begin(gl.TRIANGLES)
	v1 = (linear.Vec2{-1, 0}).Scale(math.Sqrt(float64(l.in.Buffer.ZBuffer[0]))).Add(l.in.Pos)
	for i := 1; i <= len(l.in.Buffer.ZBuffer); i++ {
		dist := math.Sqrt(float64(l.in.Buffer.ZBuffer[i%len(l.in.Buffer.ZBuffer)]))
		angle := 2 * math.Pi * (float64(i%len(l.in.Buffer.ZBuffer))/float64(len(l.in.Buffer.ZBuffer)) - 0.5)
		if dist <= 0.0 {
			continue
		}
		v0 = v1
		gl.Color4d(gl.Double(1.0-dist/math.Sqrt(float64(l.in.Horizon))), 1.0, 0.0, 1.0)
		v1 = (linear.Vec2{1, 0}).Rotate(angle).Scale(dist).Add(l.in.Pos)
		gl.Vertex2d(gl.Double(l.in.Pos.X), gl.Double(l.in.Pos.Y))
		gl.Vertex2d(gl.Double(v0.X), gl.Double(v0.Y))
		gl.Vertex2d(gl.Double(v1.X), gl.Double(v1.Y))
	}
	gl.End()
}
开发者ID:runningwild,项目名称:magnus,代码行数:19,代码来源:los.go

示例5: renderEdges

func (g *Game) renderEdges() {
	// Draw edges between nodes
	for _, ent := range g.Ents {
		cp0, ok := ent.(*ControlPoint)
		if !ok {
			continue
		}
		for _, target := range cp0.Targets {
			cp1, ok := g.Ents[target].(*ControlPoint)
			if !ok {
				continue
			}
			ally := 0
			enemy := 0
			if cp0.Side() == g.local.Side {
				ally++
			} else if cp0.Side() == -1 {
				enemy++
			}
			if cp1.Side() == g.local.Side {
				ally++
			} else if cp1.Side() == -1 {
				enemy++
			}
			if ally == 2 {
				gl.Color4ub(0, 255, 0, 255)
			} else if enemy == 2 {
				gl.Color4ub(255, 0, 0, 255)
			} else if ally == 1 {
				gl.Color4ub(255, 255, 0, 255)
			} else if enemy == 1 {
				gl.Color4ub(255, 0, 0, 255)
			} else {
				gl.Color4ub(200, 200, 200, 255)
			}
			gl.Begin(gl.LINES)
			gl.Vertex2d(gl.Double(cp0.Pos().X), gl.Double(cp0.Pos().Y))
			gl.Vertex2d(gl.Double(cp1.Pos().X), gl.Double(cp1.Pos().Y))
			gl.End()
		}
	}
}
开发者ID:runningwild,项目名称:jota,代码行数:42,代码来源:game_graphics.go

示例6: renderPlaceBlock

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()
}
开发者ID:runningwild,项目名称:jota,代码行数:11,代码来源:editor_graphics.go

示例7: renderPathing

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)
}
开发者ID:runningwild,项目名称:jota,代码行数:41,代码来源:editor_graphics.go

示例8: Draw

func (p *pullProcess) Draw(player_id int, g *game.Game) {
	gl.Color4d(1, 1, 1, 1)
	gl.Disable(gl.TEXTURE_2D)
	player := g.GetEnt(player_id).(*game.Player)
	v1 := player.Pos()
	v2 := v1.Add(linear.Vec2{1000, 0})
	v3 := v2.RotateAround(v1, player.Angle-p.Angle/2)
	v4 := v2.RotateAround(v1, player.Angle+p.Angle/2)
	gl.Begin(gl.LINES)
	vs := []linear.Vec2{v3, v4, linear.Vec2{player.X, player.Y}}
	for i := range vs {
		gl.Vertex2d(gl.Double(vs[i].X), gl.Double(vs[i].Y))
		gl.Vertex2d(gl.Double(vs[(i+1)%len(vs)].X), gl.Double(vs[(i+1)%len(vs)].Y))
	}
	gl.End()
	s := fmt.Sprintf("%.2f", p.supplied)
	base.Log().Printf("'%s'", s)
	if true {
		base.GetDictionary("luxisr").RenderString(s, 10, 10, 0, 50, gin.Left)
	}
}
开发者ID:dgthunder,项目名称:magnus,代码行数:21,代码来源:pull.go

示例9: renderLosMask

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("")
}
开发者ID:runningwild,项目名称:magnus,代码行数:45,代码来源:local.go

示例10: Draw

func (p *pullProcess) 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
	}
	gl.Color4d(1, 1, 1, 1)
	gl.Disable(gl.TEXTURE_2D)
	v1 := player.Pos()
	v2 := v1.Add(linear.Vec2{1000, 0})
	v3 := v2.RotateAround(v1, player.Angle-p.Angle/2)
	v4 := v2.RotateAround(v1, player.Angle+p.Angle/2)
	gl.Begin(gl.LINES)
	vs := []linear.Vec2{v3, v4, player.Pos()}
	for i := range vs {
		gl.Vertex2d(gl.Double(vs[i].X), gl.Double(vs[i].Y))
		gl.Vertex2d(gl.Double(vs[(i+1)%len(vs)].X), gl.Double(vs[(i+1)%len(vs)].Y))
	}
	gl.End()
}
开发者ID:runningwild,项目名称:magnus,代码行数:22,代码来源:pull.go

示例11: top

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()
}
开发者ID:knickers,项目名称:GOpenGL,代码行数:10,代码来源:segDisplay.go

示例12: upperMidRight

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()
}
开发者ID:knickers,项目名称:GOpenGL,代码行数:10,代码来源:segDisplay.go

示例13: upperLeft

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()
}
开发者ID:knickers,项目名称:GOpenGL,代码行数:10,代码来源:segDisplay.go

示例14: midRight

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()
}
开发者ID:knickers,项目名称:GOpenGL,代码行数:10,代码来源:segDisplay.go

示例15: lowerMid

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()
}
开发者ID:knickers,项目名称:GOpenGL,代码行数:10,代码来源:segDisplay.go


注:本文中的github.com/chsc/gogl/gl21.Vertex2d函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。