Exemple #1
0
func (a *app) draw(t time.Time) {
	gl.Clear(gl.COLOR_BUFFER_BIT)
	img := a.img
	w := img.Rect.Dx()
	h := img.Rect.Dy()
	gl.ActiveTexture(gl.TEXTURE0)
	upload(1, img.Y, img.YStride, w, h)
	gl.ActiveTexture(gl.TEXTURE1)
	upload(2, img.Cb, img.CStride, w/2, h/2)
	gl.ActiveTexture(gl.TEXTURE2)
	upload(3, img.Cr, img.CStride, w/2, h/2)
	if *blend {
		pimg := a.pimg
		gl.Uniform1f(a.factorloc, factor(t,
			a.tbase.Add(pimg.Timecode),
			a.tbase.Add(img.Timecode)))
		gl.ActiveTexture(gl.TEXTURE3)
		upload(4, pimg.Y, pimg.YStride, w, h)
		gl.ActiveTexture(gl.TEXTURE4)
		upload(5, pimg.Cb, pimg.CStride, w/2, h/2)
		gl.ActiveTexture(gl.TEXTURE5)
		upload(6, pimg.Cr, pimg.CStride, w/2, h/2)
	}
	gl.DrawArrays(gl.TRIANGLE_STRIP, 0, 4)
}
Exemple #2
0
// Draw draws the Sprite object.
func (sprite *Sprite) Draw(frame int) error {

	gl.BindBuffer(gl.ARRAY_BUFFER, sprite.shape.vertexBuffer)
	gl.VertexAttribPointer(gl.Uint(0), 2, gl.FLOAT, gl.FALSE, 0, gl.Offset(nil, 0))
	gl.BindAttribLocation(paunchEffect.program, gl.Uint(0), gl.GLString("position"))
	gl.BindBuffer(gl.ARRAY_BUFFER, 0)

	if sprite.texcoordBuffer != 0 {
		gl.ActiveTexture(gl.TEXTURE0)

		gl.BindBuffer(gl.ARRAY_BUFFER, sprite.texcoordBuffer)
		gl.VertexAttribPointer(gl.Uint(1), 2, gl.FLOAT, gl.FALSE, 0, gl.Offset(nil, 0))
		gl.BindAttribLocation(paunchEffect.program, gl.Uint(0), gl.GLString("texcoord"))
		gl.BindBuffer(gl.ARRAY_BUFFER, 0)

		gl.BindTexture(gl.TEXTURE_2D, sprite.texture[frame])
		gl.EnableVertexAttribArray(gl.Uint(1))
	}

	gl.EnableVertexAttribArray(gl.Uint(0))
	gl.DrawArrays(gl.TRIANGLES, 0, gl.Sizei(sprite.shape.size))
	gl.DisableVertexAttribArray(gl.Uint(0))
	gl.DisableVertexAttribArray(gl.Uint(1))

	gl.BindTexture(gl.TEXTURE_2D, 0)

	return checkForErrors()
}
Exemple #3
0
func renderPts() {
	gl.MatrixMode(gl.MODELVIEW)
	for i := minPt; i <= maxPt; i++ {
		if Pts[i].is == false {
			continue
		}
		pt := &Pts[i]
		gl.PopMatrix()
		gl.PushMatrix()
		gl.Translatef(gl.Float(pt.X), gl.Float(pt.Y), -gl.Float(pt.Z))
		gl.Scalef(gl.Float(pt.R*2), gl.Float(pt.R*2), gl.Float(pt.R*2))
		gl.DrawArrays(gl.QUADS, 0, 24)
	}
}
Exemple #4
0
// Draw draws the Shape object.
func (shape *Shape) Draw() error {

	gl.BindBuffer(gl.ARRAY_BUFFER, shape.vertexBuffer)
	vertexAttribLoc := gl.GetAttribLocation(paunchEffect.program, gl.GLString("position"))
	gl.VertexAttribPointer(gl.Uint(vertexAttribLoc), 2, gl.FLOAT, gl.FALSE, 0, gl.Offset(nil, 0))
	gl.BindBuffer(gl.ARRAY_BUFFER, 0)

	gl.EnableVertexAttribArray(gl.Uint(vertexAttribLoc))
	gl.DrawArrays(shape.mode, 0, gl.Sizei(shape.size/2))
	gl.DisableVertexAttribArray(gl.Uint(vertexAttribLoc))
	//gl.DisableVertexAttribArray(gl.Uint(1))

	//gl.BindTexture(gl.TEXTURE_2D, 0)

	return checkForErrors()
}
Exemple #5
0
// Draw a letter at a certain coordinate
func (w *glfwBackend) letter(lx, ly int, c int, cl RGB) {
	start := 8 * (ly*w.width + lx)

	vs[0] = w.verts[start]
	vs[1] = w.verts[start+1]
	vs[2] = w.verts[start+2]
	vs[3] = w.verts[start+3]
	vs[4] = w.verts[start+4]
	vs[5] = w.verts[start+5]
	vs[6] = w.verts[start+6]
	vs[7] = w.verts[start+7]

	cs[0] = cl.R
	cs[1] = cl.G
	cs[2] = cl.B
	cs[3] = cl.R
	cs[4] = cl.G
	cs[5] = cl.B
	cs[6] = cl.R
	cs[7] = cl.G
	cs[8] = cl.B
	cs[9] = cl.R
	cs[10] = cl.G
	cs[11] = cl.B

	u := float32(c%w.font.Width) * w.s
	v := float32(c/w.font.Height) * w.t
	ts[0] = u
	ts[1] = v
	ts[2] = u
	ts[3] = v + w.t
	ts[4] = u + w.s
	ts[5] = v + w.t
	ts[6] = u + w.s
	ts[7] = v

	gl.DrawArrays(gl.POLYGON, 0, 4)
}