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 } }
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("") }