本文整理匯總了Golang中github.com/chsc/gogl/gl21.Color4ub函數的典型用法代碼示例。如果您正苦於以下問題:Golang Color4ub函數的具體用法?Golang Color4ub怎麽用?Golang Color4ub使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Color4ub函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Draw
func (cpap *controlPointAttackProcess) Draw(id Gid, g *Game, side int) {
base.EnableShader("circle")
base.SetUniformF("circle", "edge", 0.9)
// For people on the controlling side this will draw a circle around the area
// that is being targeted by the control point.
if cpap.Side == side && cpap.Timer >= cpap.LockTime {
gl.Color4ub(200, 200, 200, 80)
texture.Render(
cpap.LockPos.X-50,
cpap.LockPos.Y-50,
2*50,
2*50)
}
// This draws the projectile itself.
if cpap.Timer >= cpap.FireTime {
gl.Color4ub(255, 50, 50, 240)
texture.Render(
cpap.ProjPos.X-5,
cpap.ProjPos.Y-5,
2*5,
2*5)
}
base.EnableShader("")
}
示例2: Draw
// TODO: This function really needs to take not just the side, but the player
// that this is being drawn for.
func (p *placeMineCastProcess) Draw(gid game.Gid, g *game.Game, side int) {
player, _ := g.Ents[p.PlayerGid].(*game.PlayerEnt)
if player == nil {
return
}
if side != player.Side() {
return
}
ready := int(p.Stored[game.ColorBlue] / p.Cost)
base.EnableShader("status_bar")
if ready == 0 {
gl.Color4ub(255, 0, 0, 255)
} else {
gl.Color4ub(0, 255, 0, 255)
}
var outer float32 = 0.2
var increase float32 = 0.01
frac := p.Stored[game.ColorBlue] / p.Cost
base.SetUniformF("status_bar", "frac", float32(frac-float64(ready)))
base.SetUniformF("status_bar", "inner", outer-increase*float32(ready+1))
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)
if ready > 0 {
base.SetUniformF("status_bar", "frac", 1.0)
base.SetUniformF("status_bar", "inner", outer-float32(ready)*increase)
base.SetUniformF("status_bar", "outer", outer)
texture.Render(player.Pos().X-100, player.Pos().Y-100, 200, 200)
}
base.EnableShader("")
}
示例3: Draw
func (p *multiDrain) Draw(src, obs game.Gid, game *game.Game) {
if src != obs {
return
}
ent := game.Ents[src]
if ent == nil {
return
}
base.EnableShader("status_bar")
frac := p.Stored
ready := math.Floor(frac)
if ready == 0 {
gl.Color4ub(255, 0, 0, 255)
} else {
gl.Color4ub(0, 255, 0, 255)
}
outer := 0.2
increase := 0.01
base.SetUniformF("status_bar", "frac", float32(frac-ready))
base.SetUniformF("status_bar", "inner", float32(outer-increase*(ready+1)))
base.SetUniformF("status_bar", "outer", float32(outer))
base.SetUniformF("status_bar", "buffer", 0.01)
texture.Render(ent.Pos().X-100, ent.Pos().Y-100, 200, 200)
if ready > 0 {
base.SetUniformF("status_bar", "frac", 1.0)
base.SetUniformF("status_bar", "inner", float32(outer-ready*increase))
base.SetUniformF("status_bar", "outer", float32(outer))
texture.Render(ent.Pos().X-100, ent.Pos().Y-100, 200, 200)
}
base.EnableShader("")
}
示例4: setColorForIndex
func setColorForIndex(index int) {
switch index {
case 0:
gl.Color4ub(255, 0, 0, 200)
case 1:
gl.Color4ub(0, 255, 0, 200)
case 2:
gl.Color4ub(0, 0, 255, 200)
default:
gl.Color4ub(255, 0, 255, 200)
}
}
示例5: Draw
func (fe fireExplosion) Draw(test bool) {
base.EnableShader("circle")
base.SetUniformF("circle", "edge", 0.7)
if test {
gl.Color4ub(200, 200, 200, gl.Ubyte(150*fe.Alpha()))
} else {
gl.Color4ub(255, 50, 10, gl.Ubyte(150*fe.Alpha()))
}
texture.Render(
fe.Pos.X-fe.Size(),
fe.Pos.Y-fe.Size(),
2*fe.Size(),
2*fe.Size())
base.EnableShader("")
}
示例6: Draw
func (p *PlayerEnt) Draw(game *Game) {
var t *texture.Data
var alpha gl.Ubyte
if game.local.Side == p.Side() {
alpha = gl.Ubyte(255.0 * (1.0 - p.Stats().Cloaking()/2))
} else {
alpha = gl.Ubyte(255.0 * (1.0 - p.Stats().Cloaking()))
}
gl.Color4ub(255, 255, 255, alpha)
// if p.Id() == 1 {
t = texture.LoadFromPath(filepath.Join(base.GetDataDir(), "ships/ship.png"))
// } else if p.Id() == 2 {
// t = texture.LoadFromPath(filepath.Join(base.GetDataDir(), "ships/ship3.png"))
// } else {
// t = texture.LoadFromPath(filepath.Join(base.GetDataDir(), "ships/ship2.png"))
// }
t.RenderAdvanced(
p.Position.X-float64(t.Dx())/2,
p.Position.Y-float64(t.Dy())/2,
float64(t.Dx()),
float64(t.Dy()),
p.Angle_,
false)
for _, proc := range p.Processes {
proc.Draw(p.Id(), game.local.Gid, game)
}
base.EnableShader("status_bar")
base.SetUniformF("status_bar", "inner", 0.08)
base.SetUniformF("status_bar", "outer", 0.09)
base.SetUniformF("status_bar", "buffer", 0.01)
base.SetUniformF("status_bar", "frac", 1.0)
gl.Color4ub(125, 125, 125, alpha/2)
texture.Render(p.Position.X-100, p.Position.Y-100, 200, 200)
health_frac := float32(p.Stats().HealthCur() / p.Stats().HealthMax())
if health_frac > 0.5 {
color_frac := 1.0 - (health_frac-0.5)*2.0
gl.Color4ub(gl.Ubyte(255.0*color_frac), 255, 0, alpha)
} else {
color_frac := health_frac * 2.0
gl.Color4ub(255, gl.Ubyte(255.0*color_frac), 0, alpha)
}
base.SetUniformF("status_bar", "frac", health_frac)
texture.Render(p.Position.X-100, p.Position.Y-100, 200, 200)
base.EnableShader("")
}
示例7: 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
}
}
示例8: 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()
}
示例9: drawScene
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()
}
}
示例10: 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("")
}
示例11: DrawInfo
func (ob *OptionBasic) DrawInfo(x, y, dx, dy int) {
gl.Color4ub(255, 255, 255, 255)
tx := x + (dx-ob.Large.Data().Dx())/2
ty := y + dy - ob.Large.Data().Dy()
ob.Large.Data().RenderNatural(tx, ty)
d := base.GetDictionary(ob.Size)
d.RenderParagraph(ob.Text, float64(x), float64(y+dy-ob.Large.Data().Dy())-d.MaxHeight(), 0, float64(dx), d.MaxHeight(), gui.Left, gui.Top)
}
示例12: 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)
}
示例13: 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()
}
示例14: 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()
}
}
}
示例15: Draw
func (p *asplosionProc) Draw(src, obs game.Gid, game *game.Game) {
base.EnableShader("circle")
base.SetUniformF("circle", "edge", 0.7)
gl.Color4ub(255, 50, 10, gl.Ubyte(150))
texture.Render(
p.Pos.X-p.CurrentRadius,
p.Pos.Y-p.CurrentRadius,
2*p.CurrentRadius,
2*p.CurrentRadius)
base.EnableShader("")
}