Example #1
0
func FadeRectangle(one, two Point, horizontal bool) {
	gl.Begin(gl.QUADS)
	if horizontal { // Clockwise from top right
		gl.Vertex3f(one.X, one.Y, one.Z) // Q1
		gl.Vertex3f(one.X, two.Y, one.Z) // Q4
		gl.Color3f(1, 1, 1)
		gl.Vertex3f(two.X, two.Y, two.Z) // Q3
		gl.Vertex3f(two.X, one.Y, two.Z) // Q2
	} else { // Counter clockwise from top right
		gl.Vertex3f(one.X, one.Y, one.Z) // Q1
		gl.Vertex3f(two.X, one.Y, one.Z) // Q2
		gl.Color3f(1, 1, 1)
		gl.Vertex3f(two.X, two.Y, two.Z) // Q3
		gl.Vertex3f(one.X, two.Y, two.Z) // Q4
	}
	gl.End()
}
Example #2
0
// draw draws the triangle.
func draw() {
	gl.ClearColor(0.3, 0.3, 0.3, 0.0)
	gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)

	gl.ShadeModel(gl.SMOOTH)

	gl.LoadIdentity()
	gl.Translatef(-15.0, -15.0, 0.0)

	gl.Begin(gl.TRIANGLES)

	gl.Color3f(1.0, 0.0, 0.0)
	gl.Vertex2f(0.0, 0.0)

	gl.Color3f(0.0, 1.0, 0.0)
	gl.Vertex2f(30.0, 0.0)

	gl.Color3f(0.0, 0.0, 1.0)
	gl.Vertex2f(0.0, 30.0)

	gl.End()

	win.SwapBuffers()
}
Example #3
0
func DrawStarTex(t *data.Star) {

	// Find the center point of the texture to rotate around
	xav := (t.X1 + t.X2) / 2
	yav := (t.Y1 + t.Y2) / 2

	//Translate there, rotate, translate back
	gl.MatrixMode(gl.MODELVIEW)
	gl.Translatef(xav, yav, 0)
	gl.Rotatef(gl.Float(t.Theta), 0, 0, 1)
	gl.Translatef(-xav, -yav, 0)

	//Bind our texture to be drawn by id
	gl.Color3f(1, 1, 1)
	gl.Enable(gl.TEXTURE_2D)
	gl.BindTexture(gl.TEXTURE_2D, t.TexId)

	// Draw a rectangle with the texture stretched to the corners
	gl.Begin(gl.QUADS)

	// Stretch the texture to its 4 corners.
	gl.TexCoord2d(0, 0)
	gl.Vertex2f(t.X1, t.Y1)

	gl.TexCoord2d(0, 1)
	gl.Vertex2f(t.X1, t.Y2)

	gl.TexCoord2d(1, 1)
	gl.Vertex2f(t.X2, t.Y2)

	gl.TexCoord2d(1, 0)
	gl.Vertex2f(t.X2, t.Y1)

	gl.End()

	// Unbind the texture in case something else wants to draw
	gl.Disable(gl.TEXTURE_2D)

	// Reset the matrix
	gl.LoadIdentity()

}