Beispiel #1
0
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()
	}
}
Beispiel #2
0
func interpolateColor(c1, c2 Color, f float32) Color {
	var c Color
	c.R = gl.Ubyte(float32(c1.R)*f + float32(c2.R)*(1.0-f))
	c.G = gl.Ubyte(float32(c1.G)*f + float32(c2.G)*(1.0-f))
	c.B = gl.Ubyte(float32(c1.B)*f + float32(c2.B)*(1.0-f))
	c.A = gl.Ubyte(float32(c1.A)*f + float32(c2.A)*(1.0-f))
	return c
}
Beispiel #3
0
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("")
}
Beispiel #4
0
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("")
}
Beispiel #5
0
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("")
}
Beispiel #6
0
func (m *HeatSeeker) Draw(g *Game, side int) {
	base.EnableShader("status_bar")
	base.SetUniformF("status_bar", "inner", 0.01)
	base.SetUniformF("status_bar", "outer", 0.03)
	base.SetUniformF("status_bar", "buffer", 0.01)
	base.SetUniformF("status_bar", "frac", 1.0)
	gl.Color4ub(255, 255, 255, 255)
	texture.Render(m.Position.X-100, m.Position.Y-100, 200, 200)
	base.SetUniformF("status_bar", "inner", 0.04)
	base.SetUniformF("status_bar", "outer", 0.045)
	base.SetUniformF("status_bar", "buffer", 0.01)
	health_frac := float32(m.Stats().HealthCur() / m.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, 255)
	} else {
		color_frac := health_frac * 2.0
		gl.Color4ub(255, gl.Ubyte(255.0*color_frac), 0, 255)
	}
	base.SetUniformF("status_bar", "frac", health_frac)
	texture.Render(m.Position.X-100, m.Position.Y-100, 200, 200)
	base.EnableShader("")
}
Beispiel #7
0
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()
}