예제 #1
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
	}
}
예제 #2
0
파일: los.go 프로젝트: FlyingCar/haunts
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("")
}
예제 #3
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()
}
예제 #4
0
파일: game.go 프로젝트: runningwild/magnus
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()
}
예제 #5
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()
}
예제 #6
0
파일: overlay.go 프로젝트: RickDakan/haunts
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("")
	}
}
예제 #7
0
파일: console.go 프로젝트: dgthunder/magnus
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
		}
	}
}
예제 #8
0
파일: gomandel.go 프로젝트: nsf/gomandel
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()
}
예제 #9
0
파일: gui.go 프로젝트: runningwild/jota
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)
}
예제 #10
0
파일: local.go 프로젝트: runningwild/magnus
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("")
}
예제 #11
0
파일: gui.go 프로젝트: runningwild/jota
func (b *Box) Draw(region Region, style StyleStack) {
	b.Last = region
	gl.Enable(gl.BLEND)
	gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
	gl.Disable(gl.TEXTURE_2D)
	if b.Hover {
		gl.Color4ub(gl.Ubyte(b.Color[0]), gl.Ubyte(b.Color[1]), gl.Ubyte(b.Color[2]), gl.Ubyte(b.Color[3]))
	} else {
		gl.Color4ub(gl.Ubyte(b.Color[0]), gl.Ubyte(b.Color[1]), gl.Ubyte(b.Color[2]), gl.Ubyte(b.Color[3])/2)
	}
	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+dx, y)
	gl.Vertex2i(x+dx, y+dy)
	gl.Vertex2i(x, y+dy)
	gl.End()
}
예제 #12
0
파일: manager.go 프로젝트: runningwild/jbot
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()
		})
	})
}
예제 #13
0
파일: console.go 프로젝트: runningwild/jbot
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)
	}
}
예제 #14
0
파일: console.go 프로젝트: runningwild/jota
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)
	}
}
예제 #15
0
파일: gomandel.go 프로젝트: nsf/gomandel
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)
}
예제 #16
0
파일: script.go 프로젝트: FlyingCar/haunts
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()
	}
}
예제 #17
0
파일: main.go 프로젝트: runningwild/tester
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)
		}
	}
}