當前位置: 首頁>>代碼示例>>Golang>>正文


Golang gl21.Vertex2i函數代碼示例

本文整理匯總了Golang中github.com/chsc/gogl/gl21.Vertex2i函數的典型用法代碼示例。如果您正苦於以下問題:Golang Vertex2i函數的具體用法?Golang Vertex2i怎麽用?Golang Vertex2i使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了Vertex2i函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: Draw

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
	}
}
開發者ID:runningwild,項目名稱:magnus,代碼行數:35,代碼來源:thunder_menu.go

示例2: RenderOnFloor

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("")
}
開發者ID:FlyingCar,項目名稱:haunts,代碼行數:26,代碼來源:los.go

示例3: DrawInfo

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()
}
開發者ID:ThalwegIII,項目名稱:haunts,代碼行數:10,代碼來源:ui_chooser.go

示例4: Draw

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()
}
開發者ID:runningwild,項目名稱:magnus,代碼行數:27,代碼來源:game.go

示例5: Draw

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()
}
開發者ID:runningwild,項目名稱:jota,代碼行數:31,代碼來源:game_graphics.go

示例6: Draw

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("")
	}
}
開發者ID:RickDakan,項目名稱:haunts,代碼行數:48,代碼來源:overlay.go

示例7: DrawFocused

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
		}
	}
}
開發者ID:dgthunder,項目名稱:magnus,代碼行數:47,代碼來源:console.go

示例8: drawQuad

func drawQuad(x, y, w, h int, u, v, u2, v2 float32) {
	gl.Begin(gl.QUADS)

	gl.TexCoord2f(gl.Float(u), gl.Float(v))
	gl.Vertex2i(gl.Int(x), gl.Int(y))

	gl.TexCoord2f(gl.Float(u2), gl.Float(v))
	gl.Vertex2i(gl.Int(x+w), gl.Int(y))

	gl.TexCoord2f(gl.Float(u2), gl.Float(v2))
	gl.Vertex2i(gl.Int(x+w), gl.Int(y+h))

	gl.TexCoord2f(gl.Float(u), gl.Float(v2))
	gl.Vertex2i(gl.Int(x), gl.Int(y+h))

	gl.End()
}
開發者ID:nsf,項目名稱:gomandel,代碼行數:17,代碼來源:gomandel.go

示例9: Draw

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)
}
開發者ID:runningwild,項目名稱:jota,代碼行數:17,代碼來源:gui.go

示例10: 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

示例11: setupTextureList

func setupTextureList() {
	textureListSync.Do(func() {
		render.Queue(func() {
			textureList = gl.GenLists(1)
			gl.NewList(textureList, gl.COMPILE)
			gl.Begin(gl.QUADS)
			gl.TexCoord2d(0, -1)
			gl.Vertex2i(0, 0)

			gl.TexCoord2d(0, 0)
			gl.Vertex2i(0, 1)

			gl.TexCoord2d(1, 0)
			gl.Vertex2i(1, 1)

			gl.TexCoord2d(1, -1)
			gl.Vertex2i(1, 0)
			gl.End()
			gl.EndList()
		})
	})
}
開發者ID:runningwild,項目名稱:jbot,代碼行數:22,代碼來源:manager.go

示例12: Draw

func (c *Console) Draw(x, y, dx, dy int) {
	if !gin.In().GetKeyFlat(gin.EitherShift, gin.DeviceTypeAny, gin.DeviceIndexAny).IsDown() {
		return
	}
	c.tail.GetLines(c.lines)
	gl.Enable(gl.BLEND)
	gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
	gl.Color4d(0.2, 0, 0.3, 0.8)
	gl.Disable(gl.TEXTURE_2D)
	gl.Begin(gl.QUADS)
	{
		glx := gl.Int(x)
		gly := gl.Int(y)
		glx2 := gl.Int(x + dx)
		gly2 := gl.Int(y + dy)
		gl.Vertex2i(glx, gly)
		gl.Vertex2i(glx, gly2)
		gl.Vertex2i(glx2, gly2)
		gl.Vertex2i(glx2, gly)
	}
	gl.End()
	gui.SetFontColor(1, 1, 1, 1)
	startY := float64(y + dy - len(c.lines)*lineHeight)
	for i, line := range c.lines {
		switch {
		case strings.HasPrefix(line, "LOG"):
			gui.SetFontColor(1, 1, 1, 1)
		case strings.HasPrefix(line, "WARN"):
			gui.SetFontColor(1, 1, 0, 1)
		case strings.HasPrefix(line, "ERROR"):
			gui.SetFontColor(1, 0, 0, 1)
		default:
			gui.SetFontColor(1, 1, 1, 0.7)
		}
		c.dict.RenderString(line, float64(x), startY+float64(i*lineHeight), 0, lineHeight, gui.Left)
	}
}
開發者ID:runningwild,項目名稱:jbot,代碼行數:37,代碼來源:console.go

示例13: Draw

func (c *Console) Draw(region Region, stlye StyleStack) {
	if !c.visible {
		return
	}
	gl.Enable(gl.BLEND)
	gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
	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()
	gui.SetFontColor(1, 1, 1, 1)
	startY := float64(region.Y + region.Dy - len(c.lines)*lineHeight)
	for i, line := range c.lines {
		switch {
		case strings.HasPrefix(line, "LOG"):
			gui.SetFontColor(1, 1, 1, 1)
		case strings.HasPrefix(line, "WARN"):
			gui.SetFontColor(1, 1, 0, 1)
		case strings.HasPrefix(line, "ERROR"):
			gui.SetFontColor(1, 0, 0, 1)
		default:
			gui.SetFontColor(1, 1, 1, 0.7)
		}
		c.dict.RenderString(line, float64(region.X), startY+float64(i*lineHeight), 0, lineHeight, gui.Left)
	}
}
開發者ID:runningwild,項目名稱:jota,代碼行數:36,代碼來源:console.go

示例14: drawSelection

func drawSelection(p1, p2 Point) {
	min, max := minMaxPoints(p1, p2)

	gl.Color3ub(255, 0, 0)
	gl.Begin(gl.LINES)
	gl.Vertex2i(min.X, min.Y)
	gl.Vertex2i(max.X, min.Y)

	gl.Vertex2i(min.X, min.Y)
	gl.Vertex2i(min.X, max.Y)

	gl.Vertex2i(max.X, max.Y)
	gl.Vertex2i(max.X, min.Y)

	gl.Vertex2i(max.X, max.Y)
	gl.Vertex2i(min.X, max.Y)
	gl.End()
	gl.Color3ub(255, 255, 255)
}
開發者ID:nsf,項目名稱:gomandel,代碼行數:19,代碼來源:gomandel.go

示例15: Draw

func (c *iconWithText) Draw(hovered, selected, selectable bool, region gui.Region) {
	var f float64
	switch {
	case selected:
		f = 1.0
	case hovered || selectable:
		f = 0.6
	default:
		f = 0.4
	}
	gl.Color4d(f, f, f, 1)
	c.Icon.Data().RenderNatural(region.X, region.Y)
	if hovered && selectable {
		if selected {
			gl.Color4d(1, 0, 0, 0.3)
		} else {
			gl.Color4d(1, 0, 0, 1)
		}
		gl.Disable(gl.TEXTURE_2D)
		gl.Begin(gl.LINES)
		x := int32(region.X + 1)
		y := int32(region.Y + 1)
		x2 := int32(region.X + region.Dx - 1)
		y2 := int32(region.Y + region.Dy - 1)

		gl.Vertex2i(x, y)
		gl.Vertex2i(x, y2)

		gl.Vertex2i(x, y2)
		gl.Vertex2i(x2, y2)

		gl.Vertex2i(x2, y2)
		gl.Vertex2i(x2, y)

		gl.Vertex2i(x2, y)
		gl.Vertex2i(x, y)
		gl.End()
	}
}
開發者ID:FlyingCar,項目名稱:haunts,代碼行數:39,代碼來源:script.go


注:本文中的github.com/chsc/gogl/gl21.Vertex2i函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。