Exemplo n.º 1
0
func (m Mesh) draw() {
	gl.EnableVertexAttribArray(0)
	gl.EnableVertexAttribArray(1)
	gl.EnableVertexAttribArray(2)

	if m.vbo == 0 {
		panic("attempt to set array buffer with VBO=0")
	}

	gl.BindBuffer(gl.ARRAY_BUFFER, m.vbo)
	gl.VertexAttribPointer(0, 3, gl.FLOAT, false, VertexSize*4, gl.PtrOffset(0))
	gl.VertexAttribPointer(1, 2, gl.FLOAT, false, VertexSize*4, gl.PtrOffset(12))
	gl.VertexAttribPointer(2, 3, gl.FLOAT, false, VertexSize*4, gl.PtrOffset(20))

	if m.vbo == 0 {
		panic("attempt to set element array buffer with VBO=0")
	}

	gl.BindBuffer(gl.ELEMENT_ARRAY_BUFFER, m.ibo)

	if m.size == 0 {
		panic("attempt to draw elements with mesh size = 0")
	}

	gl.DrawElements(gl.TRIANGLES, m.size, gl.UNSIGNED_INT, gl.PtrOffset(0))

	gl.DisableVertexAttribArray(0)
	gl.DisableVertexAttribArray(1)
	gl.DisableVertexAttribArray(2)
}
Exemplo n.º 2
0
func (c *Context) DisableVertexAttribArray(p Program, location string) {
	_ = c.runOnContextThread(func() error {
		l := c.locationCache.GetAttribLocation(c, p, location)
		gl.DisableVertexAttribArray(uint32(l))
		return nil
	})
}
Exemplo n.º 3
0
func onDisplay(program uint32) {
	coords := uint32(attributeCoord2d)
	vcolor := uint32(attributeVColor)

	gl.ClearColor(1.0, 1.0, 1.0, 1.0)
	gl.Clear(gl.COLOR_BUFFER_BIT)

	gl.UseProgram(program)
	gl.Enable(gl.BLEND)
	gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
	gl.Uniform1f(uniformFade, curFade)

	gl.EnableVertexAttribArray(coords)
	gl.EnableVertexAttribArray(vcolor)
	gl.BindBuffer(gl.ARRAY_BUFFER, vboTriangle)
	gl.VertexAttribPointer(coords, 2, gl.FLOAT, false, 5*floatSize, nil)
	gl.VertexAttribPointer(vcolor, 3, gl.FLOAT, false, 5*floatSize, gl.PtrOffset(2*floatSize))

	gl.DrawArrays(gl.TRIANGLES, 0, 3)

	gl.DisableVertexAttribArray(vcolor)
	gl.DisableVertexAttribArray(coords)
}
Exemplo n.º 4
0
func onDisplay(program uint32, coords uint32) {
	gl.ClearColor(1.0, 1.0, 1.0, 1.0)
	gl.Clear(gl.COLOR_BUFFER_BIT)

	gl.UseProgram(program)
	gl.EnableVertexAttribArray(coords)
	triangleVertices := []float32{
		0.0, 0.8,
		-0.8, -0.8,
		0.8, -0.8}
	gl.VertexAttribPointer(coords, 2, gl.FLOAT, false, 0, gl.Ptr(triangleVertices))
	gl.DrawArrays(gl.TRIANGLES, 0, 3)
	gl.DisableVertexAttribArray(coords)

}
Exemplo n.º 5
0
func onDisplay(program uint32, coords uint32) {
	gl.ClearColor(1.0, 1.0, 1.0, 1.0)
	gl.Clear(gl.COLOR_BUFFER_BIT)

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

	gl.UseProgram(program)
	gl.EnableVertexAttribArray(coords)

	gl.VertexAttribPointer(coords, 2, gl.FLOAT, false, 0, nil)
	gl.DrawArrays(gl.TRIANGLES, 0, 3)
	gl.DisableVertexAttribArray(coords)

}
Exemplo n.º 6
0
// DisableVertexAttribArray disables a vertex attribute array.
//
// http://www.khronos.org/opengles/sdk/docs/man3/html/glDisableVertexAttribArray.xhtml
func DisableVertexAttribArray(a Attrib) {
	gl.DisableVertexAttribArray(uint32(a.Value))
}
Exemplo n.º 7
0
func (c *Context) DisableVertexAttribArray(p Program, location string) {
	l := GetAttribLocation(c, p, location)
	gl.DisableVertexAttribArray(uint32(l))
}
Exemplo n.º 8
0
func (c *Context) DisableVertexAttribArray(index int) {
	gl.DisableVertexAttribArray(uint32(index))
}