Skip to content

Passing arrays to VertexAttribPointer

chsc edited this page Jan 27, 2013 · 1 revision

Passing arrays to VertexAttribPointer

Interleaved vertex arrays are supported with gl.Offset(pointer, offset).

With VBOs

gl.BindBuffer(gl.ARRAY_BUFFER, vertexBufferObject)

gl.EnableVertexAttribArray(0)
gl.VertexAttribPointer(0, ..., gl.Offset(nil, 0)) // same as nil

gl.EnableVertexAttribArray(1)
gl.VertexAttribPointer(1, ..., gl.Offset(nil, 12)) // skip 12 bytes

…

Without VBOs

gl.VertexAttribPointer(0, ..., gl.Offset(&vertexData[0], 0)) 
gl.VertexAttribPointer(1, ..., gl.Offset(&vertexData[0], 12))