add VertexArray.Data function

This commit is contained in:
faiface 2016-11-24 22:20:31 +01:00
parent 07dde4c8b4
commit 2bc43c7ec4
1 changed files with 11 additions and 0 deletions

View File

@ -180,6 +180,17 @@ func (va *VertexArray) Draw() {
va.End() va.End()
} }
// Data returns a copy of data inside a vertex array (actually it's vertex buffer).
func (va *VertexArray) Data() []float64 {
data := make([]float64, va.count*va.format.Size())
Do(func() {
gl.BindBuffer(gl.ARRAY_BUFFER, va.vbo)
gl.GetBufferSubData(gl.ARRAY_BUFFER, 0, 8*len(data), gl.Ptr(data))
gl.BindBuffer(gl.ARRAY_BUFFER, 0)
})
return data
}
// UpdateData overwrites the current vertex array data starting at the index offset. // UpdateData overwrites the current vertex array data starting at the index offset.
// //
// Offset is not a number of bytes, instead, it's an index in the array. // Offset is not a number of bytes, instead, it's an index in the array.