Exemple #1
0
func drawQuad(srcwidth, destwidth, srcheight, destheight float32) {
	gl.Begin(gl.QUADS)
	gl.TexCoord2i(0, 0)
	gl.Vertex2f(-1, -1)
	gl.TexCoord2i(int(srcwidth), 0)
	gl.Vertex2f(-1+destwidth, -1)
	gl.TexCoord2i(int(srcwidth), int(srcheight))
	gl.Vertex2f(-1+destwidth, -1+destheight)
	gl.TexCoord2i(0, int(srcheight))
	gl.Vertex2f(-1, -1+destheight)
	gl.End()
}
Exemple #2
0
// Same as Squarei, double co-ordinates
func Squared(x, y, w, h float64) {
	u, v, u2, v2 := 0, 1, 1, 0

	gl.TexCoord2i(u, v)
	gl.Vertex2d(x, y)

	gl.TexCoord2i(u2, v)
	gl.Vertex2d(x+w, y)

	gl.TexCoord2i(u2, v2)
	gl.Vertex2d(x+w, y+h)

	gl.TexCoord2i(u, v2)
	gl.Vertex2d(x, y+h)
}
Exemple #3
0
// Emit Vertices of a square with texture co-ordinates which wind anti-clockwise
func Squarei(x, y, w, h int) {
	u, v, u2, v2 := 0, 1, 1, 0

	gl.TexCoord2i(u, v)
	gl.Vertex2i(x, y)

	gl.TexCoord2i(u2, v)
	gl.Vertex2i(x+w, y)

	gl.TexCoord2i(u2, v2)
	gl.Vertex2i(x+w, y+h)

	gl.TexCoord2i(u, v2)
	gl.Vertex2i(x, y+h)
}
Exemple #4
0
// texcoord defines vertex texture coordinates.
// Used in classic render mode.
func (a *Attr) texcoord(i int) {
	i *= a.size

	switch a.size {
	case 1:
		switch v := a.data.(type) {
		case []int16:
			gl.TexCoord1s(v[i])
		case []int32:
			gl.TexCoord1i(int(v[i]))
		case []float32:
			gl.TexCoord1f(v[i])
		case []float64:
			gl.TexCoord1d(v[i])
		}
	case 2:
		switch v := a.data.(type) {
		case []int16:
			gl.TexCoord2s(v[i], v[i+1])
		case []int32:
			gl.TexCoord2i(int(v[i]), int(v[i+1]))
		case []float32:
			gl.TexCoord2f(v[i], v[i+1])
		case []float64:
			gl.TexCoord2d(v[i], v[i+1])
		}
	case 3:
		switch v := a.data.(type) {
		case []int16:
			gl.TexCoord3s(v[i], v[i+1], v[i+2])
		case []int32:
			gl.TexCoord3i(int(v[i]), int(v[i+1]), int(v[i+2]))
		case []float32:
			gl.TexCoord3f(v[i], v[i+1], v[i+2])
		case []float64:
			gl.TexCoord3d(v[i], v[i+1], v[i+2])
		}
	case 4:
		switch v := a.data.(type) {
		case []int16:
			gl.TexCoord4s(v[i], v[i+1], v[i+2], v[i+3])
		case []int32:
			gl.TexCoord4i(int(v[i]), int(v[i+1]), int(v[i+2]), int(v[i+3]))
		case []float32:
			gl.TexCoord4f(v[i], v[i+1], v[i+2], v[i+3])
		case []float64:
			gl.TexCoord4d(v[i], v[i+1], v[i+2], v[i+3])
		}
	}

}