示例#1
0
文件: main.go 项目: xfong/gocl
func draw() {
	if program.Value == 0 {
		initGL()
		initCL()
	}
	if numPlatforms == 0 {
		gl.ClearColor(1, 0, 0, 1)
	} else {
		gl.ClearColor(0, 1, 0, 1)
	}
	gl.Clear(gl.COLOR_BUFFER_BIT)

	gl.UseProgram(program)

	blue += 0.01
	if blue > 1 {
		blue = 0
	}
	gl.Uniform4f(color, 0, 0, blue, 1)

	gl.Uniform2f(offset, float32(touchLoc.X/geom.Width), float32(touchLoc.Y/geom.Height))

	gl.BindBuffer(gl.ARRAY_BUFFER, buf)
	gl.EnableVertexAttribArray(position)
	gl.VertexAttribPointer(position, coordsPerVertex, gl.FLOAT, false, 0, 0)
	gl.DrawArrays(gl.TRIANGLES, 0, vertexCount)
	gl.DisableVertexAttribArray(position)

	debug.DrawFPS()
}
示例#2
0
文件: main.go 项目: Miaque/mojo
func draw() {
	if scene == nil {
		loadScene()
	}

	now := clock.Time(time.Since(start) * 60 / time.Second)
	if now == lastClock {
		// TODO: figure out how to limit draw callbacks to 60Hz instead of
		// burning the CPU as fast as possible.
		// TODO: (relatedly??) sync to vblank?
		return
	}
	lastClock = now

	gl.ClearColor(1, 1, 1, 1)
	gl.Clear(gl.COLOR_BUFFER_BIT)
	eng.Render(scene, now)
	debug.DrawFPS()
}
示例#3
0
func draw() {
	gl.ClearColor(1, 0, 0, 1) // RGBA value used to clear buffer: red
	gl.Clear(gl.COLOR_BUFFER_BIT)
	debug.DrawFPS()
}