Beispiel #1
0
func drawGrid() {
	gl.Color4f(0.2, 0.2, 0.2, 1)
	gl.Begin(gl.LINES)
	for i := -0.5; i < Width; i += 1 {
		gl.Vertex2f(gl.Float(-0.5), gl.Float(i))
		gl.Vertex2f(gl.Float(life.Size), gl.Float(i))

		gl.Vertex2f(gl.Float(i), -0.5)
		gl.Vertex2f(gl.Float(i), gl.Float(life.Size))
	}
	gl.End()
}
Beispiel #2
0
func drawCells() {

	if input.Zoom > 0 {
		gl.PointSize(gl.Float(float64(Width) / float64(*flagSize) * input.Zoom))
	}

	gl.Color4f(1, 1, 1, 1)
	gl.Enable(gl.POINT_SMOOTH)
	gl.Begin(gl.POINTS)

	for i, j := 0, 0; i < (life.Size * life.Size); i, j = i+life.Size, j+1 {
		for k, v := range life.Cells[i : i+life.Size] {
			if v {
				gl.Vertex2f(gl.Float(k), gl.Float(j))
			}
		}
	}

	gl.End()
	gl.Disable(gl.POINT_SMOOTH)
}
Beispiel #3
0
func (sb *spriteBox) Draw(region gui.Region) {
	gl.Disable(gl.TEXTURE_2D)
	gl.Color4d(sb.r, sb.g, sb.b, 1)
	gl.Begin(gl.QUADS)
	gl.Vertex2i(int32(region.X+region.Dx/3), int32(region.Y))
	gl.Vertex2i(int32(region.X+region.Dx/3), int32(region.Y+region.Dy))
	gl.Vertex2i(int32(region.X+region.Dx/3*2), int32(region.Y+region.Dy))
	gl.Vertex2i(int32(region.X+region.Dx/3*2), int32(region.Y))
	gl.End()
	if sb.s != nil {
		gl.Enable(gl.TEXTURE_2D)
		tx, ty, tx2, ty2 := sb.s.Bind()
		// fmt.Printf("Tex: %f %f %f %f\n", tx, ty, tx2, ty2)
		gl.Enable(gl.BLEND)
		gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
		gl.Color4f(1, 1, 1, 1)
		gl.Begin(gl.QUADS)
		x := int32(region.X + region.Dx/2)
		y := int32(region.Y + region.Dy/2)
		gl.TexCoord2d(tx, -ty)
		gl.Vertex2i(x-50, y-75)
		gl.TexCoord2d(tx, -ty2)
		gl.Vertex2i(x-50, y+75)
		gl.TexCoord2d(tx2, -ty2)
		gl.Vertex2i(x+50, y+75)
		gl.TexCoord2d(tx2, -ty)
		gl.Vertex2i(x+50, y-75)
		gl.End()
		gl.Color4d(1, 1, 1, 1)
		text := fmt.Sprintf("%d : %s : %s", sb.s.Facing(), sb.s.Anim(), sb.s.AnimState())
		if sb.top {
			dict.RenderString(text, float64(region.X), float64(region.Y+region.Dy)-dict.MaxHeight(), 0, dict.MaxHeight(), gui.Left)
		} else {
			dict.RenderString(text, float64(region.X), float64(region.Y), 0, dict.MaxHeight(), gui.Left)
		}
	}
}
Beispiel #4
0
func drawScene() {
	gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)

	gl.MatrixMode(gl.MODELVIEW)
	gl.LoadIdentity()
	gl.Translatef(0, 0, -3.0)
	gl.Rotatef(rotx, 1, 0, 0)
	gl.Rotatef(roty, 0, 1, 0)

	rotx += 0.5
	roty += 0.5

	gl.BindTexture(gl.TEXTURE_2D, texture)

	gl.Color4f(1, 1, 1, 1)

	gl.Begin(gl.QUADS)

	gl.Normal3f(0, 0, 1)
	gl.TexCoord2f(0, 0)
	gl.Vertex3f(-1, -1, 1)
	gl.TexCoord2f(1, 0)
	gl.Vertex3f(1, -1, 1)
	gl.TexCoord2f(1, 1)
	gl.Vertex3f(1, 1, 1)
	gl.TexCoord2f(0, 1)
	gl.Vertex3f(-1, 1, 1)

	gl.Normal3f(0, 0, -1)
	gl.TexCoord2f(1, 0)
	gl.Vertex3f(-1, -1, -1)
	gl.TexCoord2f(1, 1)
	gl.Vertex3f(-1, 1, -1)
	gl.TexCoord2f(0, 1)
	gl.Vertex3f(1, 1, -1)
	gl.TexCoord2f(0, 0)
	gl.Vertex3f(1, -1, -1)

	gl.Normal3f(0, 1, 0)
	gl.TexCoord2f(0, 1)
	gl.Vertex3f(-1, 1, -1)
	gl.TexCoord2f(0, 0)
	gl.Vertex3f(-1, 1, 1)
	gl.TexCoord2f(1, 0)
	gl.Vertex3f(1, 1, 1)
	gl.TexCoord2f(1, 1)
	gl.Vertex3f(1, 1, -1)

	gl.Normal3f(0, -1, 0)
	gl.TexCoord2f(1, 1)
	gl.Vertex3f(-1, -1, -1)
	gl.TexCoord2f(0, 1)
	gl.Vertex3f(1, -1, -1)
	gl.TexCoord2f(0, 0)
	gl.Vertex3f(1, -1, 1)
	gl.TexCoord2f(1, 0)
	gl.Vertex3f(-1, -1, 1)

	gl.Normal3f(1, 0, 0)
	gl.TexCoord2f(1, 0)
	gl.Vertex3f(1, -1, -1)
	gl.TexCoord2f(1, 1)
	gl.Vertex3f(1, 1, -1)
	gl.TexCoord2f(0, 1)
	gl.Vertex3f(1, 1, 1)
	gl.TexCoord2f(0, 0)
	gl.Vertex3f(1, -1, 1)

	gl.Normal3f(-1, 0, 0)
	gl.TexCoord2f(0, 0)
	gl.Vertex3f(-1, -1, -1)
	gl.TexCoord2f(1, 0)
	gl.Vertex3f(-1, -1, 1)
	gl.TexCoord2f(1, 1)
	gl.Vertex3f(-1, 1, 1)
	gl.TexCoord2f(0, 1)
	gl.Vertex3f(-1, 1, -1)

	gl.End()
}
Beispiel #5
0
func UseColor(c Color) {
	gl.Color4f(c.R, c.G, c.B, c.A)
}
Beispiel #6
0
func display2d() {
	gl.Color4f(0, 1, 0, 1)
	shapes.Rectangle(shapes.Point{100, 100, 0}, shapes.Point{10, 10, 0}, true)
}