本文整理汇总了Golang中github.com/chsc/gogl/gl21.Vertex2d函数的典型用法代码示例。如果您正苦于以下问题:Golang Vertex2d函数的具体用法?Golang Vertex2d怎么用?Golang Vertex2d使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Vertex2d函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: lowerRight
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()
}
开发者ID:knickers,项目名称:GOpenGL,代码行数:10,代码来源:segDisplay.go
示例17: renderWalls
func (g *Game) renderWalls() {
gl.Color4d(1, 1, 1, 1)
var expandedPoly linear.Poly
for _, poly := range g.Level.Room.Walls {
// Don't draw counter-clockwise polys, specifically this means don't draw
// the boundary of the level.
if poly.IsCounterClockwise() {
continue
}
// KLUDGE: This will expand the polygon slightly so that it actually shows
// up when the los shadows are drawn over it. Eventually there should be
// separate los polys, colision polys, and draw polys so that this isn't
// necessary.
gl.Begin(gl.TRIANGLE_FAN)
expandPoly(poly, &expandedPoly)
for _, v := range expandedPoly {
gl.Vertex2d(gl.Double(v.X), gl.Double(v.Y))
}
gl.End()
}
}
开发者ID:runningwild,项目名称:jota,代码行数:21,代码来源:game_graphics.go
示例18: renderLocalArchitect
func (g *Game) renderLocalArchitect(region g2.Region, local *LocalData) {
local.architect.camera.doArchitectFocusRegion(g, local.sys)
gl.MatrixMode(gl.PROJECTION)
gl.PushMatrix()
gl.LoadIdentity()
// Set the viewport so that we only render into the region that we're supposed
// to render to.
// TODO: Check if this works on all graphics cards - I've heard that the opengl
// spec doesn't actually require that viewport does any clipping.
gl.PushAttrib(gl.VIEWPORT_BIT)
gl.Viewport(gl.Int(region.X), gl.Int(region.Y), gl.Sizei(region.Dx), gl.Sizei(region.Dy))
defer gl.PopAttrib()
current := local.architect.camera.current
gl.Ortho(
gl.Double(current.mid.X-current.dims.X/2),
gl.Double(current.mid.X+current.dims.X/2),
gl.Double(current.mid.Y+current.dims.Y/2),
gl.Double(current.mid.Y-current.dims.Y/2),
gl.Double(1000),
gl.Double(-1000),
)
defer func() {
gl.MatrixMode(gl.PROJECTION)
gl.PopMatrix()
gl.MatrixMode(gl.MODELVIEW)
}()
gl.MatrixMode(gl.MODELVIEW)
gl.Enable(gl.BLEND)
gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
zoom := local.architect.camera.current.dims.X / float64(region.Dims.Dx)
level := g.Levels[GidInvadersStart]
level.ManaSource.Draw(local, zoom, float64(level.Room.Dx), float64(level.Room.Dy))
gl.Begin(gl.LINES)
gl.Color4d(1, 1, 1, 1)
for _, poly := range g.Levels[GidInvadersStart].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.Color4ub(0, 255, 0, 255)
for side, pos := range g.Levels[GidInvadersStart].Room.Starts {
base.GetDictionary("luxisr").RenderString(fmt.Sprintf("S%d", side), pos.X, pos.Y, 0, 100, gui.Center)
}
gl.Color4d(1, 1, 1, 1)
for _, ent := range g.temp.AllEnts {
ent.Draw(g, -1) // TODO: Side isn't defined for architect yet
}
gl.Disable(gl.TEXTURE_2D)
g.renderLosMask(local)
if local.architect.abs.activeAbility != nil {
local.architect.abs.activeAbility.Draw("", g, -1) // TODO: side not defined for architect
}
}
开发者ID:runningwild,项目名称:magnus,代码行数:63,代码来源:local.go
示例19: renderLocalHelper
// For invaders or moba, does a lot of basic stuff common to both
func (g *Game) renderLocalHelper(region g2.Region, local *LocalData, camera *cameraInfo, side int) {
camera.doInvadersFocusRegion(g, side)
gl.MatrixMode(gl.PROJECTION)
gl.PushMatrix()
gl.LoadIdentity()
// Set the viewport so that we only render into the region that we're supposed
// to render to.
// TODO: Check if this works on all graphics cards - I've heard that the opengl
// spec doesn't actually require that viewport does any clipping.
gl.PushAttrib(gl.VIEWPORT_BIT)
gl.Viewport(gl.Int(region.X), gl.Int(region.Y), gl.Sizei(region.Dx), gl.Sizei(region.Dy))
defer gl.PopAttrib()
current := camera.current
gl.Ortho(
gl.Double(current.mid.X-current.dims.X/2),
gl.Double(current.mid.X+current.dims.X/2),
gl.Double(current.mid.Y+current.dims.Y/2),
gl.Double(current.mid.Y-current.dims.Y/2),
gl.Double(1000),
gl.Double(-1000),
)
defer func() {
gl.MatrixMode(gl.PROJECTION)
gl.PopMatrix()
gl.MatrixMode(gl.MODELVIEW)
}()
gl.MatrixMode(gl.MODELVIEW)
gl.Enable(gl.BLEND)
gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
level := g.Levels[GidInvadersStart]
zoom := camera.current.dims.X / float64(region.Dims.Dx)
level.ManaSource.Draw(local, zoom, float64(level.Room.Dx), float64(level.Room.Dy))
gl.Color4d(1, 1, 1, 1)
var expandedPoly linear.Poly
for _, poly := range g.Levels[GidInvadersStart].Room.Walls {
// Don't draw counter-clockwise polys, specifically this means don't draw
// the boundary of the level.
if poly.IsCounterClockwise() {
continue
}
// KLUDGE: This will expand the polygon slightly so that it actually shows
// up when the los shadows are drawn over it. Eventually there should be
// separate los polys, colision polys, and draw polys so that this isn't
// necessary.
gl.Begin(gl.TRIANGLE_FAN)
expandPoly(poly, &expandedPoly)
for _, v := range expandedPoly {
gl.Vertex2d(gl.Double(v.X), gl.Double(v.Y))
}
gl.End()
}
gui.SetFontColor(0, 255, 0, 255)
for side, pos := range g.Levels[GidInvadersStart].Room.Starts {
base.GetDictionary("luxisr").RenderString(fmt.Sprintf("S%d", side), pos.X, pos.Y, 0, 100, gui.Center)
}
gl.Color4d(1, 1, 1, 1)
for _, ent := range g.temp.AllEnts {
ent.Draw(g, side)
}
gl.Disable(gl.TEXTURE_2D)
if local.mode != LocalModeMoba {
panic("Need to implement drawing players from standard mode data")
}
for i := range local.moba.players {
p := &local.moba.players[i]
if p.abs.activeAbility != nil {
p.abs.activeAbility.Draw(p.gid, g, side)
}
}
for _, proc := range g.Processes {
proc.Draw(Gid(""), g, side)
}
gl.Color4ub(0, 0, 255, 200)
g.renderLosMask(local)
}
开发者ID:runningwild,项目名称:magnus,代码行数:84,代码来源:local.go
示例20: main
func main() {
{
f, err := os.Create("/Users/jwills/code/src/github.com/runningwild/shadertest/log.err")
if err != nil {
panic("shoot")
}
os.Stderr = f
f, err = os.Create("/Users/jwills/code/src/github.com/runningwild/shadertest/log.out")
if err != nil {
panic("shoot")
}
os.Stdout = f
}
sys.Startup()
err := gl.Init()
if err != nil {
panic(err)
}
fmt.Printf("RAWR!!!\n")
render.Init()
render.Queue(func() {
sys.CreateWindow(10, 10, wdx, wdy)
sys.EnableVSync(true)
err := gl.Init()
if err != nil {
panic(err)
}
})
base.InitShaders()
runtime.GOMAXPROCS(2)
ui, err = gui.Make(gin.In(), gui.Dims{wdx, wdy}, filepath.Join(datadir, "fonts", "skia.ttf"))
if err != nil {
panic(err)
}
anchor := gui.MakeAnchorBox(gui.Dims{wdx, wdy})
ui.AddChild(anchor)
var v float64
// var profile_output *os.File
// var num_mem_profiles int
// ui.AddChild(base.MakeConsole())
size := 19.0
base.InitShaders()
x := gl.Double(0.0)
// y := 0.0
// tex := texture.LoadFromPath(filepath.Join(base.GetDataDir(), "test/out.dff.small.png"))
fmt.Printf("RAWR!\n")
listener := Listener{}
gin.In().RegisterEventListener(&listener)
button := gin.In().GetKeyFlat(gin.ControllerButton0+6, gin.DeviceTypeController, gin.DeviceIndexAny)
fmt.Printf("RAWR!\n")
for button.FramePressCount() == 0 {
sys.Think()
// dsize := gin.In().GetKey(gin.MouseWheelVertical).FramePressAmt()
// size += dsize
// x -= float64(tex.Dx()) * dsize / 2
// y -= float64(tex.Dy()) * dsize / 2
// if gin.In().GetKey(gin.Down).FramePressAmt() > 0 {
// y += 10
// }
// if gin.In().GetKey(gin.Up).FramePressAmt() > 0 {
// y -= 10
// }
// if gin.In().GetKey(gin.Left).FramePressAmt() > 0 {
// x += 10
// }
// if gin.In().GetKey(gin.Right).FramePressAmt() > 0 {
// x -= 10
// }
render.Queue(func() {
ui.Draw()
gl.Enable(gl.BLEND)
gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
gl.Disable(gl.TEXTURE_2D)
gl.Color4ub(255, 0, 0, 255)
gl.Begin(gl.QUADS)
gl.Vertex2d(100+x, 20)
gl.Vertex2d(100+x, gl.Double(size+20))
gl.Vertex2d(200+x, gl.Double(size+20))
gl.Vertex2d(200+x, 20)
x += 1
gl.End()
gl.Enable(gl.TEXTURE_2D)
gl.Color4ub(255, 255, 255, 255)
// // str := "[email protected]#$%^&*"
// diff := 5.0 / (math.Log(size) + math.Pow(size, 0.7))
// // Works for 1200
// diff = 50 * math.Pow(base.GetDictionary("skia").Scale(), 2) / math.Pow(size, 1.0)
// // Works for 3000
// diff = 50 * math.Pow(base.GetDictionary("skia").Scale(), 1.5) / math.Pow(size, 0.8)
// //0.340637
// //0.159241
// diff = 75 * math.Pow(base.GetDictionary("skia").Scale(), 1.0) / math.Pow(size, 1.0)
// diff = 10 / math.Pow(size, 1.0)
// diff = 20/math.Pow(size, 1.0) + 5*math.Pow(base.GetDictionary("skia").Scale(), 1.0)/math.Pow(size, 1.0)
// if diff > 0.45 {
// diff = 0.45
// }
//.........这里部分代码省略.........
开发者ID:runningwild,项目名称:shadertest,代码行数:101,代码来源:main.go
注:本文中的github.com/chsc/gogl/gl21.Vertex2d函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论