func drawTexRect(tex *texture.Texture, a, b *Vec2) { tex.Bind() gl.Begin(gl.QUADS) gl.TexCoord2i(0, 0) a.Gl() gl.TexCoord2i(1, 0) V2(b.X, a.Y).Gl() gl.TexCoord2i(1, 1) b.Gl() gl.TexCoord2i(0, 1) V2(a.X, b.Y).Gl() gl.End() }
// Draw draws the given image to the open window. func (img Image) Draw(x, y int) { img.tex.Bind(gl.TEXTURE_2D) gl.Begin(gl.QUADS) gl.TexCoord2i(0, 0) gl.Vertex3i(x, y, 0) gl.TexCoord2i(1, 0) gl.Vertex3i(x+img.Width, y, 0) gl.TexCoord2i(1, 1) gl.Vertex3i(x+img.Width, y+img.Height, 0) gl.TexCoord2i(0, 1) gl.Vertex3i(x, y+img.Height, 0) gl.End() img.tex.Unbind(gl.TEXTURE_2D) }
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)) }