Exemplo n.º 1
0
func drawShip(angle gl.GLfloat) {
	gl.PushMatrix()
	gl.Translatef(x, y, 0.0)
	gl.Rotatef(angle, 0.0, 0.0, 1.0)
	if thrust {
		gl.Color3f(1.0, 0.0, 0.0)
		gl.Begin(gl.LINE_STRIP)
		gl.Vertex2f(-0.75, -0.5)
		gl.Vertex2f(-1.75, 0)
		gl.Vertex2f(-0.75, 0.5)
		gl.End()
	}
	gl.Color3f(1.0, 1.0, 0.0)
	gl.Begin(gl.LINE_LOOP)
	gl.Vertex2f(2.0, 0.0)
	gl.Vertex2f(-1.0, -1.0)
	gl.Vertex2f(-0.5, 0.0)
	gl.Vertex2f(-1.0, 1.0)
	gl.Vertex2f(2.0, 0.0)
	gl.End()
	if shield {
		gl.Color3f(0.1, 0.1, 1.0)
		gl.Begin(gl.LINE_LOOP)
		for rad := 0.0; rad < 12.0; rad += 1.0 {
			gl.Vertex2f(
				gl.GLfloat(2.3*math.Cos(2*float64(rad)/math.Pi)+0.2),
				gl.GLfloat(2.0*math.Sin(2*float64(rad)/math.Pi)))
		}
		gl.End()
	}
	gl.PopMatrix()
}
Exemplo n.º 2
0
// reset our viewport after a window resize
func resizeWindow(width, height int) {
	// protect against a divide by zero
	if height == 0 {
		height = 1
	}

	// Setup our viewport
	gl.Viewport(0, 0, width, height)

	// change to the projection matrix and set our viewing volume.
	gl.MatrixMode(gl.PROJECTION)
	gl.LoadIdentity()

	// aspect ratio
	aspect := gl.GLdouble(gl.GLfloat(width) / gl.GLfloat(height))

	// Set our perspective.
	// This code is equivalent to using gluPerspective as in the original tutorial.
	var fov, near, far gl.GLdouble
	fov = 45.0
	near = 0.1
	far = 100.0
	top := gl.GLdouble(math.Tan(float64(fov*math.Pi/360.0))) * near
	bottom := -top
	left := aspect * bottom
	right := aspect * top
	gl.Frustum(float64(left), float64(right), float64(bottom), float64(top), float64(near), float64(far))

	// Make sure we're changing the model view and not the projection
	gl.MatrixMode(gl.MODELVIEW)

	// Reset the view
	gl.LoadIdentity()
}
Exemplo n.º 3
0
func GetColor(cell int) (red, green, blue gl.GLfloat) {
	ccell := C.int(cell)

	red = gl.GLfloat(C.glutGetColor(ccell, RED))
	green = gl.GLfloat(C.glutGetColor(ccell, GREEN))
	blue = gl.GLfloat(C.glutGetColor(ccell, BLUE))

	return
}
Exemplo n.º 4
0
func initBullet(i, time int) {
	c := gl.GLfloat(math.Cos(float64(angle) * math.Pi / 180.0))
	s := gl.GLfloat(math.Sin(float64(angle) * math.Pi / 180.0))

	bullet[i].inuse = true
	bullet[i].x = x + 2*c
	bullet[i].y = y + 2*s
	bullet[i].v = 0.025
	bullet[i].xv = xv + c*bullet[i].v
	bullet[i].yv = yv + s*bullet[i].v
	bullet[i].expire = time + 1000
}
func initStars() {
	// Create the first stars
	for loop, _ := range stars {
		stars[loop] = &Star{
			angle: 0.0,
			dist:  (gl.GLfloat(loop) / gl.GLfloat(num)) * 5.0,
			r:     gl.GLubyte(rand.Float32() * 255),
			g:     gl.GLubyte(rand.Float32() * 255),
			b:     gl.GLubyte(rand.Float32() * 255),
		}
	}
}
Exemplo n.º 6
0
func advanceBullets(delta, time int) {
	for i := 0; i < MAX_BULLETS; i++ {
		if bullet[i].inuse {
			if time > bullet[i].expire {
				bullet[i].inuse = false
				continue
			}
			x := bullet[i].x + bullet[i].xv*gl.GLfloat(delta)
			y := bullet[i].y + bullet[i].yv*gl.GLfloat(delta)
			x = x / 40.0
			bullet[i].x = (x - gl.GLfloat(math.Floor(float64(x)))) * 40.0
			y = y / 40.0
			bullet[i].y = (y - gl.GLfloat(math.Floor(float64(x)))) * 40.0
		}
	}
}
Exemplo n.º 7
0
func atof(s []byte) gl.GLfloat {
	f, err := strconv.ParseFloat(string(s), 32)
	if err != nil {
		panic(err)
	}
	return gl.GLfloat(f)
}
func atof(s []byte) gl.GLfloat {
	f, err := strconv.Atof32(string(s))
	if err != nil {
		panic(err)
	}
	return gl.GLfloat(f)
}
// Here goes our drawing code
func drawGLScene(sector Sector) {
	xtrans := gl.GLfloat(-xpos)
	ztrans := gl.GLfloat(-zpos)
	ytrans := gl.GLfloat(-walkbias - 0.25)
	scenroty := gl.GLfloat(360.0 - yrot)

	// Clear the screen and depth buffer
	gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)

	// reset the view
	gl.LoadIdentity()

	// Rotate up and down to look up and down
	gl.Rotatef(float32(lookupdown), 1.0, 0.0, 0.0)
	// Rotate depending on direction player is facing
	gl.Rotatef(float32(scenroty), 0.0, 1.0, 0.0)
	// translate the scene based on player position
	gl.Translatef(float32(xtrans), float32(ytrans), float32(ztrans))

	gl.BindTexture(gl.TEXTURE_2D, uint(textures[filter]))

	for _, vertices := range sector {
		gl.Begin(gl.TRIANGLES)
		for _, triangle := range *vertices {
			gl.Normal3f(0.0, 0.0, 1.0)
			gl.TexCoord2f(float32(triangle.u), float32(triangle.v))
			gl.Vertex3f(float32(triangle.x), float32(triangle.y), float32(triangle.z))
		}
		gl.End()
	}

	// Draw to the screen
	sdl.GL_SwapBuffers()

	// Gather our frames per second
	frames++
	t := sdl.GetTicks()
	if t-t0 >= 5000 {
		seconds := (t - t0) / 1000.0
		fps := frames / seconds
		fmt.Println(frames, "frames in", seconds, "seconds =", fps, "FPS")
		t0 = t
		frames = 0
	}
}
Exemplo n.º 10
0
func reshape(w, h int) {
	gl.Viewport(0, 0, gl.GLsizei(w), gl.GLsizei(h))
	gl.MatrixMode(gl.PROJECTION)
	gl.LoadIdentity()
	gl.Ortho(0, gl.GLdouble(w), 0, gl.GLdouble(h), -1, 1)
	gl.Scalef(1, -1, 1)
	gl.Translatef(0, gl.GLfloat(-h), 0)
	gl.MatrixMode(gl.MODELVIEW)
}
Exemplo n.º 11
0
func drawMass(m *phys.Mass, dsz gl.GLfloat) {

	gl.LoadIdentity()
	//	gl.Translatef( -1.5, 0.0, -6.0 )

	v := m.Pos
	gl.Translatef(gl.GLfloat(v.X), gl.GLfloat(v.Y), gl.GLfloat(v.Z))

	/* Rotate The Triangle On The Y axis ( NEW ) */
	// gl.Rotatef( rtri, 0.0, 1.0, 0.0 );

	gl.Begin(gl.TRIANGLES)       /* Drawing Using Triangles       */
	gl.Color3f(dsz, 0.0, 0.0)    /* Red                           */
	gl.Vertex3f(0.0, dsz, 0.0)   /* Top Of Triangle (Front)       */
	gl.Color3f(0.0, dsz, 0.0)    /* Green                         */
	gl.Vertex3f(-dsz, -dsz, dsz) /* Left Of Triangle (Front)      */
	gl.Color3f(0.0, 0.0, dsz)    /* Blue                          */
	gl.Vertex3f(dsz, -dsz, dsz)  /* Right Of Triangle (Front)     */

	gl.Color3f(dsz, 0.0, 0.0)    /* Red                           */
	gl.Vertex3f(0.0, dsz, 0.0)   /* Top Of Triangle (Right)       */
	gl.Color3f(0.0, 0.0, dsz)    /* Blue                          */
	gl.Vertex3f(dsz, -dsz, dsz)  /* Left Of Triangle (Right)      */
	gl.Color3f(0.0, dsz, 0.0)    /* Green                         */
	gl.Vertex3f(dsz, -dsz, -dsz) /* Right Of Triangle (Right)     */

	gl.Color3f(dsz, 0.0, 0.0)     /* Red                           */
	gl.Vertex3f(0.0, dsz, 0.0)    /* Top Of Triangle (Back)        */
	gl.Color3f(0.0, dsz, 0.0)     /* Green                         */
	gl.Vertex3f(dsz, -dsz, -dsz)  /* Left Of Triangle (Back)       */
	gl.Color3f(0.0, 0.0, dsz)     /* Blue                          */
	gl.Vertex3f(-dsz, -dsz, -dsz) /* Right Of Triangle (Back)      */

	gl.Color3f(dsz, 0.0, 0.0)     /* Red                           */
	gl.Vertex3f(0.0, dsz, 0.0)    /* Top Of Triangle (Left)        */
	gl.Color3f(0.0, 0.0, dsz)     /* Blue                          */
	gl.Vertex3f(-dsz, -dsz, -dsz) /* Left Of Triangle (Left)       */
	gl.Color3f(0.0, dsz, 0.0)     /* Green                         */
	gl.Vertex3f(-dsz, -dsz, dsz)  /* Right Of Triangle (Left)      */
	gl.End()                      /* Finished Drawing The Triangle */

}
Exemplo n.º 12
0
func drawCube(v *Vector3) {

	gl.LoadIdentity()
	//	gl.Translatef( -1.5, 0.0, -6.0 )
	gl.Translatef(gl.GLfloat(v.X), gl.GLfloat(v.Y), gl.GLfloat(v.Z))

	/* Rotate The Triangle On The Y axis ( NEW ) */
	// gl.Rotatef( rtri, 0.0, 1.0, 0.0 );

	gl.Begin(gl.TRIANGLES)       /* Drawing Using Triangles       */
	gl.Color3f(1.0, 0.0, 0.0)    /* Red                           */
	gl.Vertex3f(0.0, 1.0, 0.0)   /* Top Of Triangle (Front)       */
	gl.Color3f(0.0, 1.0, 0.0)    /* Green                         */
	gl.Vertex3f(-1.0, -1.0, 1.0) /* Left Of Triangle (Front)      */
	gl.Color3f(0.0, 0.0, 1.0)    /* Blue                          */
	gl.Vertex3f(1.0, -1.0, 1.0)  /* Right Of Triangle (Front)     */

	gl.Color3f(1.0, 0.0, 0.0)    /* Red                           */
	gl.Vertex3f(0.0, 1.0, 0.0)   /* Top Of Triangle (Right)       */
	gl.Color3f(0.0, 0.0, 1.0)    /* Blue                          */
	gl.Vertex3f(1.0, -1.0, 1.0)  /* Left Of Triangle (Right)      */
	gl.Color3f(0.0, 1.0, 0.0)    /* Green                         */
	gl.Vertex3f(1.0, -1.0, -1.0) /* Right Of Triangle (Right)     */

	gl.Color3f(1.0, 0.0, 0.0)     /* Red                           */
	gl.Vertex3f(0.0, 1.0, 0.0)    /* Top Of Triangle (Back)        */
	gl.Color3f(0.0, 1.0, 0.0)     /* Green                         */
	gl.Vertex3f(1.0, -1.0, -1.0)  /* Left Of Triangle (Back)       */
	gl.Color3f(0.0, 0.0, 1.0)     /* Blue                          */
	gl.Vertex3f(-1.0, -1.0, -1.0) /* Right Of Triangle (Back)      */

	gl.Color3f(1.0, 0.0, 0.0)     /* Red                           */
	gl.Vertex3f(0.0, 1.0, 0.0)    /* Top Of Triangle (Left)        */
	gl.Color3f(0.0, 0.0, 1.0)     /* Blue                          */
	gl.Vertex3f(-1.0, -1.0, -1.0) /* Left Of Triangle (Left)       */
	gl.Color3f(0.0, 1.0, 0.0)     /* Green                         */
	gl.Vertex3f(-1.0, -1.0, 1.0)  /* Right Of Triangle (Left)      */
	gl.End()                      /* Finished Drawing The Triangle */

	rtri = rtri + 0.2

}
Exemplo n.º 13
0
func (f *Font) DrawText2D(x int, y int, color [3]byte, scale float, txt string) (endw int, endh int) {
	gl.LoadIdentity()
	//	gl.Translatef(0.0, 0.0, -2.0);

	glEnable2D()
	gl.Disable(gl.DEPTH_TEST)

	texture, initial, intermediarya, intermediary, w, h := f.setupTextRendering(color, txt)

	locX := gl.GLfloat(x)
	locY := gl.GLfloat(y)
	wi := gl.GLfloat(w) * gl.GLfloat(scale)
	he := gl.GLfloat(h) * gl.GLfloat(scale)

	/* Draw a quad at location */
	gl.Begin(gl.QUADS)
	/* Recall that the origin is in the lower-left corner
	   That is why the TexCoords specify different corners
	   than the Vertex coors seem to. */
	gl.TexCoord2f(0.0, 1.0)
	gl.Vertex2f(locX, locY)
	gl.TexCoord2f(1.0, 1.0)
	gl.Vertex2f(locX+wi, locY)
	gl.TexCoord2f(1.0, 0.0)
	gl.Vertex2f(locX+wi, locY+he)
	gl.TexCoord2f(0.0, 0.0)
	gl.Vertex2f(locX, locY+he)
	gl.End()

	endw, endh = f.teardownTextRendering(texture, initial, intermediarya, intermediary)

	gl.Enable(gl.DEPTH_TEST)
	glDisable2D()
	return
}
Exemplo n.º 14
0
func (f *Font) DrawText3D(pos Vector3, color [3]byte, scale float, txt string) (endw int, endh int) {

	gl.LoadIdentity()
	// 	gl.Translatef(gl.GLfloat(pos.X), gl.GLfloat(pos.Y), gl.GLfloat(-4.99));
	gl.Translatef(gl.GLfloat(pos.X), gl.GLfloat(pos.Y), gl.GLfloat(-4.99))
	gl.Scalef(gl.GLfloat(1.0/64.0*scale), gl.GLfloat(1.0/64.0*scale), gl.GLfloat(1.0))
	gl.Disable(gl.DEPTH_TEST)

	texture, initial, intermediarya, intermediary, w, h := f.setupTextRendering(color, txt)

	wi := gl.GLfloat(w)
	he := gl.GLfloat(h)
	locX := gl.GLfloat(0) - wi*0.5
	locY := gl.GLfloat(0) - he*0.5

	/* Draw a quad at location */
	gl.Begin(gl.QUADS)
	/* Recall that the origin is in the lower-left corner
	   That is why the TexCoords specify different corners
	   than the Vertex coors seem to. */

	gl.Color4f(1.0, 1.0, 0.0, 1.0)

	gl.TexCoord2f(0.0, 1.0)
	gl.Vertex3f(locX, locY, 0.0)
	gl.TexCoord2f(1.0, 1.0)
	gl.Vertex3f(locX+wi, locY, 0.0)
	gl.TexCoord2f(1.0, 0.0)
	gl.Vertex3f(locX+wi, locY+he, 0.0)
	gl.TexCoord2f(0.0, 0.0)
	gl.Vertex3f(locX, locY+he, 0.0)
	gl.End()

	endw, endh = f.teardownTextRendering(texture, initial, intermediarya, intermediary)

	gl.Enable(gl.DEPTH_TEST)
	return
}
Exemplo n.º 15
0
func reshape(w, h int) {
	/* Because Gil specified "screen coordinates" (presumably with an
	   upper-left origin), this short bit of code sets up the coordinate
	   system to correspond to actual window coodrinates.  This code
	   wouldn't be required if you chose a (more typical in 3D) abstract
	   coordinate system. */

	gl.Viewport(0, 0, gl.GLsizei(w), gl.GLsizei(h))       /* Establish viewing area to cover entire window. */
	gl.MatrixMode(gl.PROJECTION)                          /* Start modifying the projection matrix. */
	gl.LoadIdentity()                                     /* Reset project matrix. */
	gl.Ortho(0, gl.GLdouble(w), 0, gl.GLdouble(h), -1, 1) /* Map abstract coords directly to window coords. */
	gl.Scalef(1, -1, 1)                                   /* Invert Y axis so increasing Y goes down. */
	gl.Translatef(0, gl.GLfloat(-h), 0)                   /* Shift origin up to upper-left corner. */
}
Exemplo n.º 16
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()
}
Exemplo n.º 17
0
func drawCircle(t *trigger) {

	radius := float64(t.Size)
	pos := t.Pos

	gl.LoadIdentity()
	gl.Color4f(gl.GLfloat(t.Col[0]), gl.GLfloat(t.Col[1]), gl.GLfloat(t.Col[2]), gl.GLfloat(t.Col[3]))

	gl.LineWidth(2.0)
	gl.Translatef(gl.GLfloat(pos.X), gl.GLfloat(pos.Y), gl.GLfloat(pos.Z))

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

	gl.Begin(gl.POLYGON)

	for i := 0; i < 360; i++ {
		var degInRad float64 = float64(i) * DEG2RAD
		gl.Vertex3f(gl.GLfloat(math.Cos(degInRad)*radius), gl.GLfloat(math.Sin(degInRad)*radius), gl.GLfloat(0.0))
	}

	gl.End()
	gl.Disable(gl.BLEND)
}
Exemplo n.º 18
0
func drawFrame() {

	gl.LoadIdentity()
	gl.LineWidth(5.0)
	gl.Enable(gl.POINT_SMOOTH)
	gl.Enable(gl.LINE_SMOOTH)

	gl.Color4f(gl.GLfloat(FrameColor[0]), gl.GLfloat(FrameColor[1]), gl.GLfloat(FrameColor[2]), 0.1)

	m := PlayArea

	t := 1.0 * m
	b := -1.0 * m
	r := 1.0 * m
	l := -1.0 * m

	gl.Begin(gl.LINE_STRIP)

	zo := -5.0

	gl.Vertex3f(gl.GLfloat(l), gl.GLfloat(t), gl.GLfloat(zo))
	gl.Vertex3f(gl.GLfloat(r), gl.GLfloat(t), gl.GLfloat(zo))
	gl.Vertex3f(gl.GLfloat(r), gl.GLfloat(b), gl.GLfloat(zo))
	gl.Vertex3f(gl.GLfloat(l), gl.GLfloat(b), gl.GLfloat(zo))
	gl.Vertex3f(gl.GLfloat(l), gl.GLfloat(t), gl.GLfloat(zo))

	gl.End()

}
Exemplo n.º 19
0
// Here goes our drawing code
func drawGLScene() {
	// Clear the screen and depth buffer
	gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
	gl.BindTexture(gl.TEXTURE_2D, uint(texture))

	for loop, star := range stars {
		gl.LoadIdentity()
		gl.Translatef(0.0, 0.0, float32(zoom))
		gl.Rotatef(float32(tilt), 1.0, 0.0, 0.0)
		gl.Rotatef(float32(star.angle), 0.0, 1.0, 0.0)
		gl.Translatef(float32(star.dist), 0.0, 0.0)
		gl.Rotatef(float32(-star.angle), 0.0, 1.0, 0.0)
		gl.Rotatef(float32(-tilt), 1.0, 0.0, 0.0)

		if twinkle {
			other := stars[(num-loop)-1]
			gl.Color4ub(uint8(other.r), uint8(other.g), uint8(other.b), 255)
			gl.Begin(gl.QUADS)
			gl.TexCoord2f(0.0, 0.0)
			gl.Vertex3f(-1.0, -1.0, 0.0)
			gl.TexCoord2f(1.0, 0.0)
			gl.Vertex3f(1.0, -1.0, 0.0)
			gl.TexCoord2f(1.0, 1.0)
			gl.Vertex3f(1.0, 1.0, 0.0)
			gl.TexCoord2f(0.0, 1.0)
			gl.Vertex3f(-1.0, 1.0, 0.0)
			gl.End()
		}

		gl.Rotatef(float32(spin), 0.0, 0.0, 1.0)
		gl.Color4ub(uint8(star.r), uint8(star.g), uint8(star.b), 255)
		gl.Begin(gl.QUADS)
		gl.TexCoord2f(0.0, 0.0)
		gl.Vertex3f(-1.0, -1.0, 0.0)
		gl.TexCoord2f(1.0, 0.0)
		gl.Vertex3f(1.0, -1.0, 0.0)
		gl.TexCoord2f(1.0, 1.0)
		gl.Vertex3f(1.0, 1.0, 0.0)
		gl.TexCoord2f(0.0, 1.0)
		gl.Vertex3f(-1.0, 1.0, 0.0)
		gl.End()

		spin += 0.01
		star.angle += gl.GLfloat(loop) / gl.GLfloat(num)
		star.dist -= 0.01

		if star.dist < 0.0 {
			star.dist += 5.0
			star.r = gl.GLubyte(rand.Float32() * 255)
			star.g = gl.GLubyte(rand.Float32() * 255)
			star.b = gl.GLubyte(rand.Float32() * 255)
		}
	}

	// Draw to the screen
	sdl.GL_SwapBuffers()

	// Gather our frames per second
	frames++
	t := sdl.GetTicks()
	if t-t0 >= 5000 {
		seconds := (t - t0) / 1000.0
		fps := frames / seconds
		fmt.Println(frames, "frames in", seconds, "seconds =", fps, "FPS")
		t0 = t
		frames = 0
	}
}
Exemplo n.º 20
0
func idle() {
	var delta int

	time := glut.Get(glut.ELAPSED_TIME)
	if resuming {
		lastTime = time
		resuming = false
	}
	if left {
		delta = time - leftTime
		angle = angle + gl.GLfloat(delta)*gl.GLfloat(0.4)
		leftTime = time
	}
	if right {
		delta = time - rightTime
		angle = angle - gl.GLfloat(delta)*gl.GLfloat(0.4)
		rightTime = time
	}
	if thrust {
		delta = time - thrustTime
		v = gl.GLfloat(delta) * 0.00004
		xv = xv + gl.GLfloat(math.Cos(float64(angle)*math.Pi/180.0))*v
		yv = yv + gl.GLfloat(math.Sin(float64(angle)*math.Pi/180.0))*v
		thrustTime = time
	}
	delta = time - lastTime
	x = x + xv*gl.GLfloat(delta)
	y = y + yv*gl.GLfloat(delta)
	x = x / 40.0
	x = (x - gl.GLfloat(math.Floor(float64(x)))) * 40.0
	y = y / 40.0
	y = (y - gl.GLfloat(math.Floor(float64(y)))) * 40.0
	lastTime = time
	advanceBullets(delta, time)
	currentWindow.PostRedisplay()
}
Exemplo n.º 21
0
func drawWin(d float) {

	gl.LoadIdentity()
	//	gl.LineWidth(5.0)
	//	gl.Enable(gl.POINT_SMOOTH)
	//	gl.Enable(gl.LINE_SMOOTH)
	gl.Enable(gl.BLEND)
	gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)

	if d > 1.0 {
		d = 1.0
	}

	c := WinColor

	gl.Color4f(gl.GLfloat(c[0]), gl.GLfloat(c[1]), gl.GLfloat(c[2]), gl.GLfloat(d))

	m := PlayArea * 4

	t := 1.0 * m
	b := -1.0 * m
	r := 1.0 * m
	l := -1.0 * m

	gl.Begin(gl.POLYGON)

	zo := -10.0

	gl.Vertex3f(gl.GLfloat(l), gl.GLfloat(t), gl.GLfloat(zo))
	gl.Vertex3f(gl.GLfloat(r), gl.GLfloat(t), gl.GLfloat(zo))
	gl.Vertex3f(gl.GLfloat(r), gl.GLfloat(b), gl.GLfloat(zo))
	gl.Vertex3f(gl.GLfloat(l), gl.GLfloat(b), gl.GLfloat(zo))
	gl.Vertex3f(gl.GLfloat(l), gl.GLfloat(t), gl.GLfloat(zo))

	gl.End()
	gl.Disable(gl.BLEND)

}
Exemplo n.º 22
0
func drawCubes(v *Vector3) {

	gl.LoadIdentity()
	//	gl.Translatef( -1.5, 0.0, -6.0 )
	gl.Translatef(gl.GLfloat(v.X), gl.GLfloat(v.Y), gl.GLfloat(v.Z))

	/* Rotate The Triangle On The Y axis ( NEW ) */
	gl.Rotatef(rtri, 0.0, 1.0, 0.0)

	gl.Begin(gl.TRIANGLES)       /* Drawing Using Triangles       */
	gl.Color3f(1.0, 0.0, 0.0)    /* Red                           */
	gl.Vertex3f(0.0, 1.0, 0.0)   /* Top Of Triangle (Front)       */
	gl.Color3f(0.0, 1.0, 0.0)    /* Green                         */
	gl.Vertex3f(-1.0, -1.0, 1.0) /* Left Of Triangle (Front)      */
	gl.Color3f(0.0, 0.0, 1.0)    /* Blue                          */
	gl.Vertex3f(1.0, -1.0, 1.0)  /* Right Of Triangle (Front)     */

	gl.Color3f(1.0, 0.0, 0.0)    /* Red                           */
	gl.Vertex3f(0.0, 1.0, 0.0)   /* Top Of Triangle (Right)       */
	gl.Color3f(0.0, 0.0, 1.0)    /* Blue                          */
	gl.Vertex3f(1.0, -1.0, 1.0)  /* Left Of Triangle (Right)      */
	gl.Color3f(0.0, 1.0, 0.0)    /* Green                         */
	gl.Vertex3f(1.0, -1.0, -1.0) /* Right Of Triangle (Right)     */

	gl.Color3f(1.0, 0.0, 0.0)     /* Red                           */
	gl.Vertex3f(0.0, 1.0, 0.0)    /* Top Of Triangle (Back)        */
	gl.Color3f(0.0, 1.0, 0.0)     /* Green                         */
	gl.Vertex3f(1.0, -1.0, -1.0)  /* Left Of Triangle (Back)       */
	gl.Color3f(0.0, 0.0, 1.0)     /* Blue                          */
	gl.Vertex3f(-1.0, -1.0, -1.0) /* Right Of Triangle (Back)      */

	gl.Color3f(1.0, 0.0, 0.0)     /* Red                           */
	gl.Vertex3f(0.0, 1.0, 0.0)    /* Top Of Triangle (Left)        */
	gl.Color3f(0.0, 0.0, 1.0)     /* Blue                          */
	gl.Vertex3f(-1.0, -1.0, -1.0) /* Left Of Triangle (Left)       */
	gl.Color3f(0.0, 1.0, 0.0)     /* Green                         */
	gl.Vertex3f(-1.0, -1.0, 1.0)  /* Right Of Triangle (Left)      */
	gl.End()                      /* Finished Drawing The Triangle */

	rtri = rtri + 0.2

	return

	/* Move Right 3 Units */
	gl.LoadIdentity()
	gl.Translatef(1.5, 0.0, -6.0)

	/* Rotate The Quad On The X axis ( NEW ) */
	gl.Rotatef(rquad, 1.0, 0.0, 0.0)

	/* Set The Color To Blue One Time Only */
	gl.Color3f(0.5, 0.5, 1.0)

	gl.Begin(gl.QUADS)           /* Draw A Quad                      */
	gl.Color3f(0.0, 1.0, 0.0)    /* Set The Color To Green           */
	gl.Vertex3f(1.0, 1.0, -1.0)  /* Top Right Of The Quad (Top)      */
	gl.Vertex3f(-1.0, 1.0, -1.0) /* Top Left Of The Quad (Top)       */
	gl.Vertex3f(-1.0, 1.0, 1.0)  /* Bottom Left Of The Quad (Top)    */
	gl.Vertex3f(1.0, 1.0, 1.0)   /* Bottom Right Of The Quad (Top)   */

	gl.Color3f(1.0, 0.5, 0.0)     /* Set The Color To Orange          */
	gl.Vertex3f(1.0, -1.0, 1.0)   /* Top Right Of The Quad (Botm)     */
	gl.Vertex3f(-1.0, -1.0, 1.0)  /* Top Left Of The Quad (Botm)      */
	gl.Vertex3f(-1.0, -1.0, -1.0) /* Bottom Left Of The Quad (Botm)   */
	gl.Vertex3f(1.0, -1.0, -1.0)  /* Bottom Right Of The Quad (Botm)  */

	gl.Color3f(1.0, 0.0, 0.0)    /* Set The Color To Red             */
	gl.Vertex3f(1.0, 1.0, 1.0)   /* Top Right Of The Quad (Front)    */
	gl.Vertex3f(-1.0, 1.0, 1.0)  /* Top Left Of The Quad (Front)     */
	gl.Vertex3f(-1.0, -1.0, 1.0) /* Bottom Left Of The Quad (Front)  */
	gl.Vertex3f(1.0, -1.0, 1.0)  /* Bottom Right Of The Quad (Front) */

	gl.Color3f(1.0, 1.0, 0.0)     /* Set The Color To Yellow          */
	gl.Vertex3f(1.0, -1.0, -1.0)  /* Bottom Left Of The Quad (Back)   */
	gl.Vertex3f(-1.0, -1.0, -1.0) /* Bottom Right Of The Quad (Back)  */
	gl.Vertex3f(-1.0, 1.0, -1.0)  /* Top Right Of The Quad (Back)     */
	gl.Vertex3f(1.0, 1.0, -1.0)   /* Top Left Of The Quad (Back)      */

	gl.Color3f(0.0, 0.0, 1.0)     /* Set The Color To Blue            */
	gl.Vertex3f(-1.0, 1.0, 1.0)   /* Top Right Of The Quad (Left)     */
	gl.Vertex3f(-1.0, 1.0, -1.0)  /* Top Left Of The Quad (Left)      */
	gl.Vertex3f(-1.0, -1.0, -1.0) /* Bottom Left Of The Quad (Left)   */
	gl.Vertex3f(-1.0, -1.0, 1.0)  /* Bottom Right Of The Quad (Left)  */

	gl.Color3f(1.0, 0.0, 1.0)    /* Set The Color To Violet          */
	gl.Vertex3f(1.0, 1.0, -1.0)  /* Top Right Of The Quad (Right)    */
	gl.Vertex3f(1.0, 1.0, 1.0)   /* Top Left Of The Quad (Right)     */
	gl.Vertex3f(1.0, -1.0, 1.0)  /* Bottom Left Of The Quad (Right)  */
	gl.Vertex3f(1.0, -1.0, -1.0) /* Bottom Right Of The Quad (Right) */
	gl.End()                     /* Done Drawing The Quad            */

	rquad -= 0.15
}