示例#1
0
文件: gldebug.go 项目: Miaque/mojo
func EnableVertexAttribArray(index Attrib) {
	defer func() {
		errstr := errDrain()
		log.Printf("gl.EnableVertexAttribArray(%v) %v", index, errstr)
	}()
	C.glEnableVertexAttribArray(index.c())
}
示例#2
0
文件: gl.go 项目: extrame/gl
// EnableAttrib calls glEnableVertexAttribArray and glVertexAttribPointer to activate an attribute and connect it to a buffer object.
// offset specifies the first vertex, stride specifies the distance from the beginning of one vertex to the next, size specifies the number of components in a vertex (all these arguments are in units of array elements, not bytes like the underlying API).
// The byte offset of component j of vertex i is thus calculated as: sizeof(data[0]) * (offset + stride * i + j), where data is the parameter passed to Buffer.Set
func (p *Program) EnableAttrib(loc string, buf *Buffer, offset int, size int, stride int, norm bool) {
	n := FALSE
	if norm {
		n = TRUE
	}
	buf.Bind(ARRAY_BUFFER)
	attr := p.attr[loc]
	C.glEnableVertexAttribArray(attr)
	C.glVertexAttribPointer(attr, C.GLint(size), buf.t, C.GLboolean(n), C.GLsizei(stride*buf.ts), unsafe.Pointer(uintptr(buf.ts*offset)))
	buf.Unbind(ARRAY_BUFFER)
}
示例#3
0
func (game *game) initGL() {
	log.Printf("GL_VERSION: %v GL_RENDERER: %v GL_VENDOR %v\n",
		GetString(C.GL_VERSION), GetString(C.GL_RENDERER), GetString(C.GL_VENDOR))
	log.Printf("GL_EXTENSIONS: %v\n", GetString(C.GL_EXTENSIONS))
	C.glClearColor(0.0, 0.0, 0.0, 1.0)
	C.glEnable(C.GL_CULL_FACE)
	C.glEnable(C.GL_DEPTH_TEST)

	game.prog = createProgram(vertShaderSrcDef, fragShaderSrcDef)
	posAttrib := attribLocation(game.prog, "vPosition")
	game.offsetUni = uniformLocation(game.prog, "offset")
	game.colorUni = uniformLocation(game.prog, "color")
	C.glUseProgram(game.prog)
	C.glEnableVertexAttribArray(C.GLuint(posAttrib))

	vertVBO := GenBuffer()
	checkGLError()
	C.glBindBuffer(C.GL_ARRAY_BUFFER, vertVBO)
	verts := []float32{.0, 0.5, -0.5, -0.5, 0.5, -0.5}
	C.glBufferData(C.GL_ARRAY_BUFFER, C.GLsizeiptr(len(verts)*int(unsafe.Sizeof(verts[0]))), unsafe.Pointer(&verts[0]), C.GL_STATIC_DRAW)
	C.glVertexAttribPointer(C.GLuint(posAttrib), 2, C.GL_FLOAT, C.GL_FALSE, 0, unsafe.Pointer(uintptr(0)))
}
示例#4
0
func EnableVertexAttribArray(a Attrib) {
	C.glEnableVertexAttribArray(a.c())
}
示例#5
0
文件: gles2.go 项目: remogatto/egles
func EnableVertexAttribArray(
	index uint32) {
	C.glEnableVertexAttribArray(
		C.GLuint(index))
}
示例#6
0
func (indx AttribLocation) EnableArray() {
	C.glEnableVertexAttribArray(C.GLuint(indx))
}
示例#7
0
func (attrib vattrib) Enable() {
	C.glEnableVertexAttribArray(attrib.index)
}
示例#8
0
// EnableVertexAttribArray enables a vertex attribute array.
//
// http://www.khronos.org/opengles/sdk/docs/man3/html/glEnableVertexAttribArray.xhtml
func EnableVertexAttribArray(index Attrib) {
	C.glEnableVertexAttribArray(index.c())
}
示例#9
0
文件: vertices.go 项目: eaburns/gl
// Enable enables a generic vertex attribute array.
func (l VertexAttribArray) Enable() {
	C.glEnableVertexAttribArray(C.GLuint(l))
}