示例#1
0
func display() {
	// Clear the background as white
	gl.ClearColor(1.0, 1.0, 1.0, 1.0)
	gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)

	// Use the GLSL program
	program.Use()

	uniformTexture.Uniform1i(0)

	attributeCoord3d.EnableArray()
	vboCubeVertices.Bind(gl.ARRAY_BUFFER)
	attributeCoord3d.AttribPointerOffset(3, gl.FLOAT, false, 0, 0)

	texture.Bind(gl.TEXTURE_2D)

	attributeTexCoord.EnableArray()
	vboCubeTexCoords.Bind(gl.ARRAY_BUFFER)
	attributeTexCoord.AttribPointerOffset(2, gl.FLOAT, false, 0, 0)

	iboCubeElements.Bind(gl.ELEMENT_ARRAY_BUFFER)
	//size := []int32{0}
	//gl.GetBufferParameteriv(gl.ELEMENT_ARRAY_BUFFER, gl.BUFFER_SIZE, size)
	gl.DrawElementsOffset(gl.TRIANGLES, len(cubeElements), gl.UNSIGNED_SHORT, 0)

	attributeCoord3d.DisableArray()
	attributeTexCoord.DisableArray()

	// Display the result
	glfw.SwapBuffers()
}
示例#2
0
func display() {
	gl.Clear(gl.COLOR_BUFFER_BIT)
	bitmap_output(40, 35, "This is written in a GLUT bitmap font.", glut.BITMAP_TIMES_ROMAN_24)
	bitmap_output(30, 210, "More bitmap text is a fixed 9 by 15 font.", glut.BITMAP_9_BY_15)
	bitmap_output(70, 240, "                Helvetica is yet another bitmap font.", glut.BITMAP_HELVETICA_18)

	gl.MatrixMode(gl.PROJECTION)
	gl.PushMatrix()
	gl.LoadIdentity()
	glu.Perspective(40.0, 1.0, 0.1, 20.0)
	gl.MatrixMode(gl.MODELVIEW)
	gl.PushMatrix()
	// Banthar's glu doesn't have this right now.
	// glu.LookAt(0.0, 0.0, 4.0, /* eye is at (0,0,30) */
	// 	0.0, 0.0, 0.0, /* center is at (0,0,0) */
	// 	0.0, 1.0, 0.) /* up is in postivie Y direction */
	gl.PushMatrix()
	gl.Translatef(0, 0, -4)
	gl.Rotatef(50, 0, 1, 0)
	stroke_output(-2.5, 1.1, "  This is written in a", glut.STROKE_ROMAN)
	stroke_output(-2.5, 0, " GLUT stroke font.", glut.STROKE_ROMAN)
	stroke_output(-2.5, -1.1, "using 3D perspective.", glut.STROKE_ROMAN)
	gl.PopMatrix()
	gl.MatrixMode(gl.MODELVIEW)
	gl.PopMatrix()
	gl.MatrixMode(gl.PROJECTION)
	gl.PopMatrix()
	gl.MatrixMode(gl.MODELVIEW)
	gl.Flush()
}
示例#3
0
func display() {
	// Clear the background as white
	gl.ClearColor(1.0, 1.0, 1.0, 1.0)
	gl.Clear(gl.COLOR_BUFFER_BIT)

	// Use the GLSL program
	program.Use()

	// Faster fade in and out than in the wikibook
	curFade := math.Sin(glfw.Time())

	uniformFade.Uniform1f(float32(curFade))

	vboTriangle.Bind(gl.ARRAY_BUFFER)

	attributeCoord2d.EnableArray()
	// Describe our vertices array to OpenGL (it can't guess its format automatically)
	attributeCoord2d.AttribPointerOffset(2, gl.FLOAT, false, 5*4, 0)

	attributeColor.EnableArray()
	attributeColor.AttribPointerOffset(3, gl.FLOAT, false, 5*4, 2*4)

	// Push each element in buffer_vertices to the vertex shader
	gl.DrawArrays(gl.TRIANGLES, 0, 3)

	attributeCoord2d.DisableArray()
	attributeColor.DisableArray()

	// Display the result
	glfw.SwapBuffers()
}
示例#4
0
func display() {
	// Clear the background as white
	gl.ClearColor(1.0, 1.0, 1.0, 1.0)
	gl.Clear(gl.COLOR_BUFFER_BIT)

	// Use the GLSL program
	program.Use()

	uniformMTransform.UniformMatrix4fv(1, false, matrix)

	vboTriangle.Bind(gl.ARRAY_BUFFER)

	attributeCoord3d.EnableArray()
	// Describe our vertices array to OpenGL (it can't guess its format automatically)
	attributeCoord3d.AttribPointerOffset(3, gl.FLOAT, false, 6*4, 0)

	attributeColor.EnableArray()
	attributeColor.AttribPointerOffset(3, gl.FLOAT, false, 6*4, 3*4)

	// Push each element in buffer_vertices to the vertex shader
	gl.DrawArrays(gl.TRIANGLES, 0, 3)

	attributeCoord3d.DisableArray()
	attributeColor.DisableArray()

	// Display the result
	glfw.SwapBuffers()
}
示例#5
0
func main() {

	sdl.Init(sdl.INIT_VIDEO)

	var screen = sdl.SetVideoMode(640, 480, 32, sdl.OPENGL)

	if screen == nil {
		panic("sdl error")
	}

	if gl.Init() != 0 {
		panic("glew error")
	}

	pen := Pen{}

	gl.MatrixMode(gl.PROJECTION)

	gl.Viewport(0, 0, gl.GLsizei(screen.W), gl.GLsizei(screen.H))
	gl.LoadIdentity()
	gl.Ortho(0, gl.GLdouble(screen.W), gl.GLdouble(screen.H), 0, -1.0, 1.0)

	gl.ClearColor(1, 1, 1, 0)
	gl.Clear(gl.COLOR_BUFFER_BIT)

	var running = true

	for running {

		e := &sdl.Event{}

		for e.Poll() {
			switch e.Type {
			case sdl.QUIT:
				running = false
				break
			case sdl.KEYDOWN:
				running = false
				break
			case sdl.MOUSEMOTION:
				me := e.MouseMotion()
				if me.State != 0 {
					pen.lineTo(Point{int(me.X), int(me.Y)})
				} else {
					pen.moveTo(Point{int(me.X), int(me.Y)})
				}
				break
			}
		}

		sdl.GL_SwapBuffers()
		sdl.Delay(25)
	}

	sdl.Quit()

}
示例#6
0
文件: main.go 项目: skelterjohn/glfw
func main() {
	var err os.Error
	if err = glfw.Init(); err != nil {
		fmt.Fprintf(os.Stderr, "%v\n", err)
		return
	}

	defer glfw.Terminate()

	// Open window with FSAA samples (if possible).
	glfw.OpenWindowHint(glfw.FsaaSamples, 4)

	if err = glfw.OpenWindow(400, 400, 0, 0, 0, 0, 0, 0, glfw.Windowed); err != nil {
		fmt.Fprintf(os.Stderr, "%v\n", err)
		return
	}

	defer glfw.CloseWindow()

	glfw.SetWindowTitle("Aliasing Detector")
	glfw.SetSwapInterval(1)

	if samples := glfw.WindowParam(glfw.FsaaSamples); samples != 0 {
		fmt.Fprintf(os.Stdout, "Context reports FSAA is supported with %d samples\n", samples)
	} else {
		fmt.Fprintf(os.Stdout, "Context reports FSAA is unsupported\n")
	}

	gl.MatrixMode(gl.PROJECTION)
	glu.Perspective(0, 1, 0, 1)

	for glfw.WindowParam(glfw.Opened) == 1 {
		time := float32(glfw.Time())

		gl.Clear(gl.COLOR_BUFFER_BIT)

		gl.LoadIdentity()
		gl.Translatef(0.5, 0, 0)
		gl.Rotatef(time, 0, 0, 1)

		gl.Enable(GL_MULTISAMPLE_ARB)
		gl.Color3f(1, 1, 1)
		gl.Rectf(-0.25, -0.25, 0.25, 0.25)

		gl.LoadIdentity()
		gl.Translatef(-0.5, 0, 0)
		gl.Rotatef(time, 0, 0, 1)

		gl.Disable(GL_MULTISAMPLE_ARB)
		gl.Color3f(1, 1, 1)
		gl.Rectf(-0.25, -0.25, 0.25, 0.25)
		glfw.SwapBuffers()
	}
}
示例#7
0
func draw() {
	xtrans := -xpos
	ztrans := -zpos
	ytrans := -walkbias - 0.25
	scenroty := 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(lookupdown, 1.0, 0.0, 0.0)
	// Rotate depending on direction player is facing
	gl.Rotatef(scenroty, 0.0, 1.0, 0.0)
	// translate the scene based on player position
	gl.Translatef(xtrans, ytrans-1.75, ztrans)

	for _, chunk := range chunks {
		for y := 0; y < 16; y++ {
			for x := 0; x < 16; x++ {
				for z := 0; z <= 16; z++ {
					if len(chunk.Data[y][x]) > z && chunk.Data[y][x][z] != "" {
						gl.PushMatrix()
						gl.Translated(
							float64(16*chunk.X+x),
							float64(z),
							float64(16*chunk.Y+y))
						gl.CallList(cubes[chunk.Data[y][x][z]])
						gl.PopMatrix()
					}
				}
			}
		}
	}

	gl.PopMatrix()

	sdl.GL_SwapBuffers()

	Frames++
	{
		t := sdl.GetTicks()
		if t-T0 >= 5000 {
			seconds := (t - T0) / 1000.0
			fps := Frames / seconds
			print(Frames, " frames in ", seconds, " seconds = ", fps, " FPS\n")
			T0 = t
			Frames = 0
		}
	}
}
示例#8
0
func main() {

	sdl.Init(sdl.INIT_VIDEO)

	var screen = sdl.SetVideoMode(640, 480, 32, sdl.OPENGL)

	if screen == nil {
		panic("sdl error")
	}

	if gl.Init() != 0 {
		panic("gl error")
	}

	pen := Pen{}

	gl.MatrixMode(gl.PROJECTION)

	gl.Viewport(0, 0, int(screen.W), int(screen.H))
	gl.LoadIdentity()
	gl.Ortho(0, float64(screen.W), float64(screen.H), 0, -1.0, 1.0)

	gl.ClearColor(1, 1, 1, 0)
	gl.Clear(gl.COLOR_BUFFER_BIT)

	var running = true

	for running {

		for e := sdl.PollEvent(); e != nil; e = sdl.PollEvent() {
			switch ev := e.(type) {
			case *sdl.QuitEvent:
				running = false
			case *sdl.KeyboardEvent:
				if ev.Keysym.Sym == sdl.K_ESCAPE {
					running = false
				}
			case *sdl.MouseMotionEvent:
				if ev.State != 0 {
					pen.lineTo(Point{int(ev.X), int(ev.Y)})
				} else {
					pen.moveTo(Point{int(ev.X), int(ev.Y)})
				}
			}
		}

		sdl.GL_SwapBuffers()
		sdl.Delay(25)
	}

	sdl.Quit()

}
示例#9
0
文件: simple.go 项目: awpr/Go-GLUT
func display() {
	gl.Clear(gl.COLOR_BUFFER_BIT)
	gl.Begin(gl.TRIANGLES)
	gl.Color3f(0.0, 0.0, 1.0) /* blue */
	gl.Vertex2i(0, 0)
	gl.Color3f(0.0, 1.0, 0.0) /* green */
	gl.Vertex2i(200, 200)
	gl.Color3f(1.0, 0.0, 0.0) /* red */
	gl.Vertex2i(20, 200)
	gl.End()
	gl.Flush() /* Single buffered, so needs a flush. */
}
// Here goes our drawing code
func drawGLScene() {
	// Clear the screen and depth buffer
	gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)

	// Move left 1.5 units and into the screen 6.0 units.
	gl.LoadIdentity()
	gl.Translatef(-1.5, 0.0, -6.0)
	gl.Rotatef(float32(rtri), 0.0, 1.0, 0.0) // Rotate the triangle on the Y axis

	gl.Begin(gl.TRIANGLES)       // Draw triangles
	gl.Color3f(1.0, 0.0, 0.0)    // Set The Color To Red
	gl.Vertex3f(0.0, 1.0, 0.0)   // top
	gl.Color3f(0.0, 1.0, 0.0)    // Set The Color To Red
	gl.Vertex3f(-1.0, -1.0, 0.0) // bottom left
	gl.Color3f(0.0, 0.0, 1.0)    // Set The Color To Red
	gl.Vertex3f(1.0, -1.0, 0.0)  // bottom right
	gl.End()                     // finish drawing the triangle

	// Move right 3 units
	gl.LoadIdentity()
	gl.Translatef(1.5, 0.0, -6.0)
	gl.Color3f(0.5, 0.5, 1.0)                 // Set The Color To Blue One Time Only
	gl.Rotatef(float32(rquad), 1.0, 0.0, 0.0) // rotate the quad on the X axis

	gl.Begin(gl.QUADS)           // draw quads
	gl.Vertex3f(-1.0, 1.0, 0.0)  // top left
	gl.Vertex3f(1.0, 1.0, 0.0)   // top right
	gl.Vertex3f(1.0, -1.0, 0.0)  // bottom right
	gl.Vertex3f(-1.0, -1.0, 0.0) // bottom left
	gl.End()                     // done drawing the quad

	// Draw to the screen
	sdl.GL_SwapBuffers()

	rtri += 0.2   // Increase The Rotation Variable For The Triangle
	rquad -= 0.15 // Decrease The Rotation Variable For The Quad

	// 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
	}
}
// 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
	}
}
示例#12
0
func draw() {

	gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)

	gl.PushMatrix()
	gl.Rotated(view_rotx, 1.0, 0.0, 0.0)
	gl.Rotated(view_roty, 0.0, 1.0, 0.0)
	gl.Rotated(view_rotz, 0.0, 0.0, 1.0)

	gl.PushMatrix()
	gl.Translated(-3.0, -2.0, 0.0)
	gl.Rotated(angle, 0.0, 0.0, 1.0)
	gl.CallList(gear1)
	gl.PopMatrix()

	gl.PushMatrix()
	gl.Translated(3.1, -2.0, 0.0)
	gl.Rotated(-2.0*angle-9.0, 0.0, 0.0, 1.0)
	gl.CallList(gear2)
	gl.PopMatrix()

	gl.PushMatrix()
	gl.Translated(-3.1, 4.2, 0.0)
	gl.Rotated(-2.0*angle-25.0, 0.0, 0.0, 1.0)
	gl.CallList(gear3)
	gl.PopMatrix()

	gl.PopMatrix()

	glfw.SwapBuffers()

	Frames++
	{
		t := glfw.Time()
		if t-T0 >= 5 {
			seconds := (t - T0)
			fps := float64(Frames) / seconds
			print(Frames, " frames in ", int(seconds), " seconds = ", int(fps), " FPS\n")
			T0 = t
			Frames = 0
		}
	}
}
示例#13
0
func draw() {

	gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)

	gl.PushMatrix()
	gl.Rotated(view_rotx, 1.0, 0.0, 0.0)
	gl.Rotated(view_roty, 0.0, 1.0, 0.0)
	gl.Rotated(view_rotz, 0.0, 0.0, 1.0)

	gl.PushMatrix()
	gl.Translated(-3.0, -2.0, 0.0)
	gl.Rotated(angle, 0.0, 0.0, 1.0)
	gl.CallList(gear1)
	gl.PopMatrix()

	gl.PushMatrix()
	gl.Translated(3.1, -2.0, 0.0)
	gl.Rotated(-2.0*angle-9.0, 0.0, 0.0, 1.0)
	gl.CallList(gear2)
	gl.PopMatrix()

	gl.PushMatrix()
	gl.Translated(-3.1, 4.2, 0.0)
	gl.Rotated(-2.0*angle-25.0, 0.0, 0.0, 1.0)
	gl.CallList(gear3)
	gl.PopMatrix()

	gl.PopMatrix()

	sdl.GL_SwapBuffers()

	Frames++
	{
		t := sdl.GetTicks()
		if t-T0 >= 5000 {
			seconds := (t - T0) / 1000.0
			fps := Frames / seconds
			print(Frames, " frames in ", seconds, " seconds = ", fps, " FPS\n")
			T0 = t
			Frames = 0
		}
	}
}
示例#14
0
func display() {
	gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
	gl.LineWidth(1)
	gc := draw2dgl.NewGraphicContext(width, height)

	gc.Translate(380, 400)
	gc.Scale(1, -1)
	rotate = (rotate + 1) % 360
	gc.Rotate(float64(rotate) * math.Pi / 180)
	gc.Translate(-380, -400)
	interpreter := postscript.NewInterpreter(gc)
	reader := strings.NewReader(postscriptContent)
	lastTime := time.Now()
	interpreter.Execute(reader)
	dt := time.Now().Sub(lastTime)
	log.Printf("Redraw in : %f ms\n", float64(dt)*1e-6)
	gl.Flush() /* Single buffered, so needs a flush. */
	glut.PostRedisplay()
}
// Here goes our drawing code
func drawGLScene() {
	// Clear the screen and depth buffer
	gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)

	// reset the view
	gl.LoadIdentity()

	// 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
	}
}
示例#16
0
func draw(triangles p2t.TriArray) {

	gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)

	for i := 0; i < len(triangles); i++ {
		var t = triangles[i]
		var a = t.Point[0]
		var b = t.Point[1]
		var c = t.Point[2]

		// Red
		gl.Color3f(1, 0, 0)

		gl.Begin(gl.LINE_LOOP)
		gl.Vertex2f(float32(a.X), float32(a.Y))
		gl.Vertex2f(float32(b.X), float32(b.Y))
		gl.Vertex2f(float32(c.X), float32(c.Y))
		gl.End()
	}

	sdl.GL_SwapBuffers()
}
示例#17
0
// Here goes our drawing code
func drawGLScene() {
	// Clear the screen and depth buffer
	gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)

	// Move left 1.5 units and into the screen 6.0 units.
	gl.LoadIdentity()
	gl.Translatef(-1.5, 0.0, -6.0)

	gl.Begin(gl.TRIANGLES)       // Draw triangles
	gl.Vertex3f(0.0, 1.0, 0.0)   // top
	gl.Vertex3f(-1.0, -1.0, 0.0) // bottom left
	gl.Vertex3f(1.0, -1.0, 0.0)  // bottom right
	gl.End()                     // finish drawing the triangle

	// Move right 3 units
	gl.Translatef(3.0, 0.0, 0.0)

	gl.Begin(gl.QUADS)           // draw quads
	gl.Vertex3f(-1.0, 1.0, 0.0)  // top left
	gl.Vertex3f(1.0, 1.0, 0.0)   // top right
	gl.Vertex3f(1.0, -1.0, 0.0)  // bottom right
	gl.Vertex3f(-1.0, -1.0, 0.0) // bottom left
	gl.End()                     // done drawing the quad

	// 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
	}
}
示例#18
0
func main() {
	runtime.LockOSThread()
	flag.Parse()
	buildPalette()
	sdl.Init(sdl.INIT_VIDEO)
	defer sdl.Quit()

	sdl.GL_SetAttribute(sdl.GL_SWAP_CONTROL, 1)

	if sdl.SetVideoMode(512, 512, 32, sdl.OPENGL) == nil {
		panic("sdl error")
	}

	if gl.Init() != 0 {
		panic("gl error")
	}

	sdl.WM_SetCaption("Gomandel", "Gomandel")

	gl.Enable(gl.TEXTURE_2D)
	gl.Viewport(0, 0, 512, 512)
	gl.MatrixMode(gl.PROJECTION)
	gl.LoadIdentity()
	gl.Ortho(0, 512, 512, 0, -1, 1)

	gl.ClearColor(0, 0, 0, 0)

	//-----------------------------------------------------------------------------
	var dndDragging bool = false
	var dndStart Point
	var dndEnd Point
	var tex gl.Texture
	var tc TexCoords
	var lastProgress int
	initialRect := Rect{-1.5, -1.5, 3, 3}
	rect := initialRect

	rc := new(MandelbrotRequest)
	rc.MakeRequest(512, 512, rect)
	rc.WaitFor(Small, &tex, &tc)

	running := true
	e := new(sdl.Event)
	for running {
		for e.Poll() {
			switch e.Type {
			case sdl.QUIT:
				running = false
			case sdl.MOUSEBUTTONDOWN:
				dndDragging = true
				sdl.GetMouseState(&dndStart.X, &dndStart.Y)
				dndEnd = dndStart
			case sdl.MOUSEBUTTONUP:
				dndDragging = false
				sdl.GetMouseState(&dndEnd.X, &dndEnd.Y)
				if e.MouseButton().Button == 3 {
					rect = initialRect
				} else {
					rect = rectFromSelection(dndStart, dndEnd, 512, 512, rect)
					tc = texCoordsFromSelection(dndStart, dndEnd, 512, 512, tc)
				}

				// make request
				rc.MakeRequest(512, 512, rect)
			case sdl.MOUSEMOTION:
				if dndDragging {
					sdl.GetMouseState(&dndEnd.X, &dndEnd.Y)
				}
			}
		}

		// if we're waiting for a result, check if it's ready
		p := rc.Update(&tex, &tc)
		if p != -1 {
			lastProgress = p
		}

		gl.Clear(gl.COLOR_BUFFER_BIT)
		tex.Bind(gl.TEXTURE_2D)
		drawQuad(0, 0, 512, 512, tc.TX, tc.TY, tc.TX2, tc.TY2)
		gl.BindTexture(gl.TEXTURE_2D, 0)
		if dndDragging {
			drawSelection(dndStart, dndEnd)
		}
		drawProgress(512, 512, lastProgress, rc.Pending)
		sdl.GL_SwapBuffers()
	}
}
// 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
	}
}
示例#20
0
文件: main.go 项目: rolfrm/boxworld
func main() {
	//ABSPTest()
	//return
	glfw.Init(800, 600)
	InitPhysics()

	world := new(World)
	world.Init()
	world.GameObjects = new(list.List)
	player := MakeMan(Vec3{10, 20, 10})

	world.Add(player)
	world.Add(ropetest(Vec3{0, 40, 0}, 4, 4))
	world.Add(treeThing(Vec3{20, 20, 20}, 3))
	world.Add(MakePlayer(Vec3{-20, 20, 0}).Body)
	world.Add(MakePlayer(Vec3{-20, 50, 0}).Body)

	world.Add(MakePlayer(Vec3{-20, 70, 0}).Body)
	world.Add(MakePlayer(Vec3{-20, 90, 0}).Body)
	world.Add(MakePlayer(Vec3{-20, 110, 0}).Body)
	/*for i := 0; i < 100; i++ {
		world.Add(SetPlayerAnimation(MakePlayer(Vec3{float32(int(i%10))*50,0,float32(i*2) - 200})).Body)
	}*/
	world.Add(NewGameObj(Vec3{0, -20, 0}, Vec3{10000, 10, 10000}, Vec3{0, 0.5, 0.1}, float32(math.Inf(1)), 10, nil))

	//world.Add(SetPlayerAnimation(MakePlayer(Vec3{-20,120,0})).Body)

	qtn := new(ABSPNode)
	qtn.Root = qtn
	//qtn.Position = Vec3{-10000,-10000,-10000}
	//qtn.Size = Vec3{20000,20000,20000}
	for i := world.GameObjects.Front(); i != nil; i = i.Next() {
		gobj := i.Value.(*GameObj)
		all := gobj.GetSubs()
		for i := 0; i < len(all); i++ {
			qtn.Insert(all[i])
		}
	}
	world.GameObjectTree = qtn
	fmt.Println("Total:", len(qtn.Data))
	qtn.Divide()
	cols := 0
	qtn.cd(func(obj1, obj2 SPData) {
		cols += 1
	})
	fmt.Println(cols)
	//qtn.Traverse(0)
	//return
	gl.Init()
	vs := gl.CreateShader(gl.VERTEX_SHADER)
	vs.Source(
		LoadFileToString("s1.vert"))
	vs.Compile()

	fs := gl.CreateShader(gl.FRAGMENT_SHADER)
	fs.Source(LoadFileToString("s1.frag"))
	fs.Compile()

	pg := gl.CreateProgram()
	pg.AttachShader(vs)
	pg.AttachShader(fs)
	pg.Link()
	pg.Validate()

	pg.Use()
	fmt.Println("**Shader log**")
	fmt.Println(fs.GetInfoLog())
	fmt.Println(vs.GetInfoLog())
	fmt.Println(pg.GetInfoLog())
	fmt.Println("******END*****")

	gl.ClearColor(0.5, 0.5, 1, 0)
	gl.Enable(gl.DEPTH_TEST)
	gl.Enable(gl.BLEND)
	gl.Enable(gl.POLYGON_SMOOTH)
	gl.Hint(gl.POLYGON_SMOOTH_HINT, gl.NICEST)

	var t float64
	t = float64(time.Nanoseconds()) / 1000000000
	cam1 := Camera{player, 100, Vec3{0, 0, 0}}
	glfw.AddListener(func(m glfw.MouseMoveEvent) {
		cam1.Angle.X = float32(m.X-400) / 400 * 3.14 * 2
		cam1.Angle.Y = float32(m.Y-300) / 300 * 3.14 * 2
		//player.Rotation = Vec3{cam1.Angle.X,cam1.Angle.Y,0}
	})
	glfw.AddListener(func(mw glfw.MouseWheelEvent) {
		cam1.Distance = 100 + float32(mw.Pos*mw.Pos*mw.Pos)
	})

	world.CompilePhysicsObjects()
	for it := 0; it < 10000; it += 1 {
		cam1.Setup()
		dt := float32(0.005)
		t = float64(float64(time.Nanoseconds()) / 1000000000)
		UpdatePositions(world.PhysicsObjects, dt)

		UpdateModelStates(world.PhysicsObjects)

		UpdateCollisions(world.GameObjectTree, dt)
		UpdateModelStates(world.PhysicsObjects)
		gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
		DrawWorld(world.GameObjects, dt, pg)
		glfw.SwapBuffers()
		pt := float64(float64(time.Nanoseconds()) / 1000000000)
		sleeptime := (float64(dt) - (pt - t)) * 10e8
		fmt.Println("Sleep for:", sleeptime)
		time.Sleep(int64(sleeptime))
	}

}
示例#21
0
// Here goes our drawing code
func drawGLScene() {
	// Clear the screen and depth buffer
	gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)

	// Move left 1.5 units and into the screen 6.0 units.
	gl.LoadIdentity()
	gl.Translatef(0.0, 0.0, -7.0)

	gl.Rotatef(float32(xrot), 1.0, 0.0, 0.0) /* Rotate On The X Axis */
	gl.Rotatef(float32(yrot), 0.0, 1.0, 0.0) /* Rotate On The Y Axis */
	gl.Rotatef(float32(zrot), 0.0, 0.0, 1.0) /* Rotate On The Z Axis */

	/* Select Our Texture */
	gl.BindTexture(gl.TEXTURE_2D, uint(texture))

	gl.Begin(gl.QUADS) // Draw a quad
	/* Front Face */
	gl.TexCoord2f(0.0, 1.0)
	gl.Vertex3f(-1.0, -1.0, 1.0) // Bottom left
	gl.TexCoord2f(1.0, 1.0)
	gl.Vertex3f(1.0, -1.0, 1.0) // Bottom right
	gl.TexCoord2f(1.0, 0.0)
	gl.Vertex3f(1.0, 1.0, 1.0) // Top right
	gl.TexCoord2f(0.0, 0.0)
	gl.Vertex3f(-1.0, 1.0, 1.0) // Top left

	/* Back Face */
	gl.TexCoord2f(0.0, 0.0)
	gl.Vertex3f(-1.0, -1.0, -1.0) // Bottom right
	gl.TexCoord2f(0.0, 1.0)
	gl.Vertex3f(-1.0, 1.0, -1.0) // Top right
	gl.TexCoord2f(1.0, 1.0)
	gl.Vertex3f(1.0, 1.0, -1.0) // Top left
	gl.TexCoord2f(1.0, 0.0)
	gl.Vertex3f(1.0, -1.0, -1.0) // Bottom left

	/* Top Face */
	gl.TexCoord2f(1.0, 1.0)
	gl.Vertex3f(-1.0, 1.0, -1.0) // Top left
	gl.TexCoord2f(1.0, 0.0)
	gl.Vertex3f(-1.0, 1.0, 1.0) // Bottom left
	gl.TexCoord2f(0.0, 0.0)
	gl.Vertex3f(1.0, 1.0, 1.0) // Bottom right
	gl.TexCoord2f(0.0, 1.0)
	gl.Vertex3f(1.0, 1.0, -1.0) // Top right

	/* Bottom Face */
	gl.TexCoord2f(0.0, 1.0)
	gl.Vertex3f(-1.0, -1.0, -1.0) // Top right
	gl.TexCoord2f(1.0, 1.0)
	gl.Vertex3f(1.0, -1.0, -1.0) // Top left
	gl.TexCoord2f(1.0, 0.0)
	gl.Vertex3f(1.0, -1.0, 1.0) // Bottom left
	gl.TexCoord2f(0.0, 0.0)
	gl.Vertex3f(-1.0, -1.0, 1.0) // Bottom right

	/* Right face */
	gl.TexCoord2f(0.0, 0.0)
	gl.Vertex3f(1.0, -1.0, -1.0) // Bottom right
	gl.TexCoord2f(0.0, 1.0)
	gl.Vertex3f(1.0, 1.0, -1.0) // Top right
	gl.TexCoord2f(1.0, 1.0)
	gl.Vertex3f(1.0, 1.0, 1.0) // Top left
	gl.TexCoord2f(1.0, 0.0)
	gl.Vertex3f(1.0, -1.0, 1.0) // Bottom left

	/* Left Face */
	gl.TexCoord2f(1.0, 0.0)
	gl.Vertex3f(-1.0, -1.0, -1.0) // Bottom left
	gl.TexCoord2f(0.0, 0.0)
	gl.Vertex3f(-1.0, -1.0, 1.0) // Bottom right
	gl.TexCoord2f(0.0, 1.0)
	gl.Vertex3f(-1.0, 1.0, 1.0) // Top right
	gl.TexCoord2f(1.0, 1.0)
	gl.Vertex3f(-1.0, 1.0, -1.0) // Top left
	gl.End()                     // done drawing the quad

	// Draw to the screen
	sdl.GL_SwapBuffers()

	xrot += 0.3 /* X Axis Rotation */
	yrot += 0.2 /* Y Axis Rotation */
	zrot += 0.4 /* Z Axis Rotation */

	// 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
	}
}
示例#22
0
文件: ogl_graphics.go 项目: chsc/g3
func (gd *openGLGraphicsDevice) Clear() {
	gl.ClearColor(0.0, 0.0, 1.0, 0.5)
	gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
}
示例#23
0
// Here goes our drawing code
func drawGLScene() {
  // Clear the screen and depth buffer
  gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)

  // Move left 1.5 units and into the screen 6.0 units.
  gl.LoadIdentity()
  gl.Translatef(0.0, 0.0, float32(z)) // translate by z

  gl.Rotatef(float32(xrot), 1.0, 0.0, 0.0) /* Rotate On The X Axis */
  gl.Rotatef(float32(yrot), 0.0, 1.0, 0.0) /* Rotate On The Y Axis */

  /* Select Our Texture */
  gl.BindTexture(gl.TEXTURE_2D, uint(textures[filter])) // based on filter

  gl.Begin(gl.QUADS)

  // Front face
  gl.Normal3f(0.0, 0.0, 1.0) // Normal Pointing Towards Viewer
  gl.TexCoord2f(0.0, 1.0); gl.Vertex3f(-1.0, -1.0, 1.0) // Bottom left
  gl.TexCoord2f(1.0, 1.0); gl.Vertex3f( 1.0, -1.0, 1.0) // Bottom right
  gl.TexCoord2f(1.0, 0.0); gl.Vertex3f( 1.0,  1.0, 1.0) // Top right
  gl.TexCoord2f(0.0, 0.0); gl.Vertex3f(-1.0,  1.0, 1.0) // Top left

  // Back Face
  gl.Normal3f(0.0, 0.0, -1.0) // Normal Pointing Away From Viewer
  gl.TexCoord2f(0.0, 0.0); gl.Vertex3f(-1.0, -1.0, -1.0) // Bottom right
  gl.TexCoord2f(0.0, 1.0); gl.Vertex3f(-1.0,  1.0, -1.0) // Top right
  gl.TexCoord2f(1.0, 1.0); gl.Vertex3f( 1.0,  1.0, -1.0) // Top left
  gl.TexCoord2f(1.0, 0.0); gl.Vertex3f( 1.0, -1.0, -1.0) // Bottom left

  // Top Face
  gl.Normal3f(0.0, 1.0, 0.0) // Normal Pointing Up
  gl.TexCoord2f(1.0, 1.0); gl.Vertex3f(-1.0,  1.0, -1.0) // Top left
  gl.TexCoord2f(1.0, 0.0); gl.Vertex3f(-1.0,  1.0,  1.0) // Bottom left
  gl.TexCoord2f(0.0, 0.0); gl.Vertex3f( 1.0,  1.0,  1.0) // Bottom right
  gl.TexCoord2f(0.0, 1.0); gl.Vertex3f( 1.0,  1.0, -1.0) // Top right

  // Bottom Face
  gl.Normal3f(0.0, -1.0, 0.0) // Normal Pointing Down
  gl.TexCoord2f(0.0, 1.0); gl.Vertex3f(-1.0, -1.0, -1.0) // Top right
  gl.TexCoord2f(1.0, 1.0); gl.Vertex3f( 1.0, -1.0, -1.0) // Top left
  gl.TexCoord2f(1.0, 0.0); gl.Vertex3f( 1.0, -1.0,  1.0) // Bottom left
  gl.TexCoord2f(0.0, 0.0); gl.Vertex3f(-1.0, -1.0,  1.0) // Bottom right

  // Right face
  gl.Normal3f(1.0, 0.0, 0.0) // Normal Pointing Right
  gl.TexCoord2f(0.0, 0.0); gl.Vertex3f(1.0, -1.0, -1.0) // Bottom right
  gl.TexCoord2f(0.0, 1.0); gl.Vertex3f(1.0,  1.0, -1.0) // Top right
  gl.TexCoord2f(1.0, 1.0); gl.Vertex3f(1.0,  1.0,  1.0) // Top left
  gl.TexCoord2f(1.0, 0.0); gl.Vertex3f(1.0, -1.0,  1.0) // Bottom left

  // Left Face
  gl.Normal3f(-1.0, 0.0, 0.0) // Normal Pointing Left
  gl.TexCoord2f(1.0, 0.0); gl.Vertex3f(-1.0, -1.0, -1.0) // Bottom left
  gl.TexCoord2f(0.0, 0.0); gl.Vertex3f(-1.0, -1.0,  1.0) // Bottom right
  gl.TexCoord2f(0.0, 1.0); gl.Vertex3f(-1.0,  1.0,  1.0) // Top right
  gl.TexCoord2f(1.0, 1.0); gl.Vertex3f(-1.0,  1.0, -1.0) // Top left

  gl.End()

  sdl.GL_SwapBuffers()

  xrot += xspeed
  yrot += yspeed

  // 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
  }
}
示例#24
0
func display() {
	gl.Clear(gl.COLOR_BUFFER_BIT)
	drawShip(angle)
	drawBullets()
	glut.SwapBuffers()
}
示例#25
0
文件: main.go 项目: jcd/go-gamelib
func main() {
	sch = sched.NewScheduler(0)

	flag.Parse()

	cmd := selectCommand(CmdNum)

	SetupVideo()

	// Let the selected command initialize
	cmd.OnSetup()

	// Extract sleep time between frames for this command
	sleeptime := cmd.SleepTime()

	var frames uint32 = 0
	// var t0 uint32 = sdl.GetTicks()
	// 	gt := sdl.GetTicks

	if ShowFPS {
		sch.AddInterval(1.0, 2, func(tc sched.TaskChan, sc *sched.Scheduler) {

			val := <-tc
			if val != sched.RUNNING {
				sc.C <- sched.TaskResult{val, tc}
				return
			}
			sc.C <- sched.TaskResult{sched.COMPLETED, tc}

			// seconds := (t - t0) / 1000.0
			// fps := float(frames) / float(1.0)
			// os.Stdout.WriteString("Fdafsda")
			//sch.LOG <- "FPS"
			// fmt.Println("FPS")
			return
			// t0 = t
			frames = 0

		})
	}

	var running = true

	for running {

		e := &sdl.Event{}

		for e.Poll() {
			switch e.Type {
			case sdl.QUIT:
				running = false
				break
			case sdl.KEYDOWN:
				kb := e.Keyboard()
				KeySym = kb.Keysym.Sym
				if KeySym == sdl.K_ESCAPE {
					running = false
				}
				break
			case sdl.MOUSEBUTTONUP, sdl.MOUSEBUTTONDOWN:
				me := e.MouseButton()
				MouseState = me.State
				break
			case sdl.MOUSEMOTION:
				me := e.MouseMotion()
				MouseX = int(me.X)
				MouseY = int(me.Y)
				MouseState = me.State
				break
			case sdl.VIDEORESIZE:
				me := (*sdl.ResizeEvent)(cast(e))
				sdl.SetVideoMode(int(me.W), int(me.H), 32, SDL_FLAGS)
				ResizeWindow(me.W, me.H)
			}
		}

		// sch.Update()
		cmd.OnUpdate()
		gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
		cmd.OnDraw()
		sdl.GL_SwapBuffers()

		if sleeptime != 0 {
			sdl.Delay(uint32(sleeptime))
		}
		frames++
	}

	sdl.Quit()

}
示例#26
0
文件: gotris.go 项目: sonald/gotris
func main() {
	runtime.LockOSThread()
	flag.Parse()
	sdl.Init(sdl.INIT_VIDEO)
	defer sdl.Quit()

	sdl.GL_SetAttribute(sdl.GL_SWAP_CONTROL, 1)

	if sdl.SetVideoMode(640, 480, 32, sdl.OPENGL) == nil {
		panic("sdl error")
	}

	sdl.WM_SetCaption("Gotris", "Gotris")
	sdl.EnableKeyRepeat(250, 45)

	gl.Enable(gl.TEXTURE_2D)
	gl.Enable(gl.BLEND)
	gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
	gl.Viewport(0, 0, 640, 480)
	gl.MatrixMode(gl.PROJECTION)
	gl.LoadIdentity()
	gl.Ortho(0, 640, 480, 0, -1, 1)

	gl.ClearColor(0, 0, 0, 0)

	//-----------------------------------------------------------------------------

	font, err := LoadFontFromFile("dejavu.font")
	if err != nil {
		panic(err)
	}

	rand.Seed(int64(sdl.GetTicks()))

	gs := NewGameSession(*initLevel, font)
	lastTime := sdl.GetTicks()

	running := true
	for running {
		for ev := sdl.PollEvent(); ev != nil; ev = sdl.PollEvent() {
			switch e := ev.(type) {
			case *sdl.QuitEvent:
				running = false
			case *sdl.KeyboardEvent:
				if e.Type == sdl.KEYDOWN {
					running = gs.HandleKey(e.Keysym.Sym)
				}
			}
		}

		now := sdl.GetTicks()
		delta := now - lastTime
		lastTime = now

		gs.Update(delta)

		gl.Clear(gl.COLOR_BUFFER_BIT)
		font.Draw(5, 5, fmt.Sprintf("Level: %d | Score: %d", gs.Level, gs.Score))
		gs.Draw()
		gl.Color3ub(255, 255, 255)
		sdl.GL_SwapBuffers()
	}
}
示例#27
0
// Here goes our drawing code
func drawGLScene() {
	// Clear the screen and depth buffer
	gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)

	// Move left 1.5 units and into the screen 6.0 units.
	gl.LoadIdentity()
	gl.Translatef(-1.5, 0.0, -6.0)
	gl.Rotatef(float32(rtri), 0.0, 1.0, 0.0) // Rotate the triangle on the Y axis

	gl.Begin(gl.TRIANGLES) // Draw 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() // finish drawing the triangle

	// Move right 3 units
	gl.LoadIdentity()
	gl.Translatef(1.5, 0.0, -7.0)
	gl.Rotatef(float32(rquad), 1.0, 1.0, 1.0) // rotate the quad on the X axis

	gl.Begin(gl.QUADS)            // draw quads
	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 (Bottom)
	gl.Vertex3f(-1.0, -1.0, 1.0)  // Top Left Of The Quad (Bottom)
	gl.Vertex3f(-1.0, -1.0, -1.0) // Bottom Left Of The Quad (Bottom)
	gl.Vertex3f(1.0, -1.0, -1.0)  // Bottom Right Of The Quad (Bottom)
	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

	// Draw to the screen
	sdl.GL_SwapBuffers()

	rtri += 0.2   // Increase The Rotation Variable For The Triangle
	rquad -= 0.15 // Decrease The Rotation Variable For The Quad

	// 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
	}
}