Esempio n. 1
0
func (pen *Pen) lineTo(p Point) {

	gl.Enable(gl.BLEND)
	gl.Enable(gl.POINT_SMOOTH)
	gl.Enable(gl.LINE_SMOOTH)
	gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)

	gl.Color4f(0.0, 0.0, 0.0, 0.1)

	gl.Begin(gl.LINES)

	for _, s := range pen.points {

		if s.x == 0 && s.y == 0 {
			continue
		}

		if p.distanceTo(s) < 20.0 {

			gl.Vertex2i(gl.GLint(p.x), gl.GLint(p.y))
			gl.Vertex2i(gl.GLint(s.x), gl.GLint(s.y))

		}

	}

	gl.End()

	pen.n = (pen.n + 1) % len(pen.points)
	pen.points[pen.n] = p

	pen.moveTo(p)

}
Esempio n. 2
0
func drawBlock(x, y int, color TetrisBlockColor) {
	glx := gl.GLint(x)
	gly := gl.GLint(y)

	gl.Color3ub(color.R/2, color.G/2, color.B/2)
	gl.Begin(gl.QUADS)
	gl.Vertex2i(int(glx), int(gly))
	gl.Vertex2i(int(glx+blockSize), int(gly))
	gl.Vertex2i(int(glx+blockSize), int(gly+blockSize))
	gl.Vertex2i(int(glx), int(gly+blockSize))
	gl.Color3ub(color.R, color.G, color.B)
	gl.Vertex2i(int(glx+smallBlockOffset), int(gly+smallBlockOffset))
	gl.Vertex2i(int(glx+blockSize-smallBlockOffset), int(gly+smallBlockOffset))
	gl.Vertex2i(int(glx+blockSize-smallBlockOffset), int(gly+blockSize-smallBlockOffset))
	gl.Vertex2i(int(glx+smallBlockOffset), int(gly+blockSize-smallBlockOffset))
	gl.End()
}
Esempio n. 3
0
func Build2DMipmaps(target gl.GLenum, internalFormat gl.GLint, width, height gl.GLsizei, format, kind gl.GLenum, data unsafe.Pointer) gl.GLint {
	return gl.GLint(C.gluBuild2DMipmaps(
		C.GLenum(target),
		C.GLint(internalFormat),
		C.GLsizei(width),
		C.GLsizei(height),
		C.GLenum(format),
		C.GLenum(kind),
		data,
	))
}
Esempio n. 4
0
func drawQuad(x, y, w, h int, u, v, u2, v2 float) {
	gl.Begin(gl.QUADS)

	gl.TexCoord2f(gl.GLfloat(u), gl.GLfloat(v))
	gl.Vertex2i(gl.GLint(x), gl.GLint(y))

	gl.TexCoord2f(gl.GLfloat(u2), gl.GLfloat(v))
	gl.Vertex2i(gl.GLint(x+w), gl.GLint(y))

	gl.TexCoord2f(gl.GLfloat(u2), gl.GLfloat(v2))
	gl.Vertex2i(gl.GLint(x+w), gl.GLint(y+h))

	gl.TexCoord2f(gl.GLfloat(u), gl.GLfloat(v2))
	gl.Vertex2i(gl.GLint(x), gl.GLint(y+h))

	gl.End()
}
Esempio n. 5
0
func drawSelection(p1, p2 Point) {
	min, max := minMaxPoints(p1, p2)

	gl.Color3ub(255, 0, 0)
	gl.Begin(gl.LINES)
	gl.Vertex2i(gl.GLint(min.X), gl.GLint(min.Y))
	gl.Vertex2i(gl.GLint(max.X), gl.GLint(min.Y))

	gl.Vertex2i(gl.GLint(min.X), gl.GLint(min.Y))
	gl.Vertex2i(gl.GLint(min.X), gl.GLint(max.Y))

	gl.Vertex2i(gl.GLint(max.X), gl.GLint(max.Y))
	gl.Vertex2i(gl.GLint(max.X), gl.GLint(min.Y))

	gl.Vertex2i(gl.GLint(max.X), gl.GLint(max.Y))
	gl.Vertex2i(gl.GLint(min.X), gl.GLint(max.Y))
	gl.End()
	gl.Color3ub(255, 255, 255)
}