Example #1
0
func (t *Skybox) RenderScaled(center, scale *Vec3) {
	v := []*Vec3{
		V3(-1, -1, 1),
		V3(1, -1, 1),
		V3(1, 1, 1),
		V3(-1, 1, 1),
		V3(-1, -1, -1),
		V3(1, -1, -1),
		V3(1, 1, -1),
		V3(-1, 1, -1)}
	for i := 0; i < 8; i++ {
		v[i].Muli(scale).Addi(center)
	}

	if globals.UseShader {
		program.Unuse()
	}

	//*//save attributes and change them
	gl.PushAttrib(gl.ENABLE_BIT | gl.TEXTURE_BIT)
	defer gl.PopAttrib() //reset to old attributes
	gl.Enable(gl.TEXTURE_2D)
	gl.Disable(gl.DEPTH_TEST)
	gl.Disable(gl.LIGHTING)
	gl.Disable(gl.BLEND) //*/
	oneSide := func(tex *texture.Texture, a, b, c, d int, n *Vec3) {
		tex.BindForSkybox(color.White)
		gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE)
		gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE)
		gl.Begin(gl.TRIANGLES)
		gl.Normal3dv(n.Slc())
		gl.TexCoord2i(0, 0)
		gl.Vertex3dv(v[a].Slc())
		gl.TexCoord2i(1, 0)
		gl.Vertex3dv(v[b].Slc())
		gl.TexCoord2i(1, 1)
		gl.Vertex3dv(v[c].Slc())
		gl.TexCoord2i(0, 0)
		gl.Vertex3dv(v[a].Slc())
		gl.TexCoord2i(1, 1)
		gl.Vertex3dv(v[c].Slc())
		gl.TexCoord2i(0, 1)
		gl.Vertex3dv(v[d].Slc())
		gl.End()
	}
	oneSide(t.up, 2, 3, 7, 6, V3(0, -1, 0))
	oneSide(t.dn, 5, 4, 0, 1, V3(0, 1, 0))
	oneSide(t.lt, 5, 1, 2, 6, V3(1, 0, 0))
	oneSide(t.rt, 0, 4, 7, 3, V3(-1, 0, 0))
	oneSide(t.ft, 1, 0, 3, 2, V3(0, 0, -1))
	oneSide(t.bk, 4, 5, 6, 7, V3(0, 0, 1))
}
Example #2
0
func (v *Vec3) Gl() {
	gl.Vertex3dv(v.Slc())
}