From 2bc43c7ec410b9045fc25680d7a6ff837993fb48 Mon Sep 17 00:00:00 2001 From: faiface <faiface@ksp.sk> Date: Thu, 24 Nov 2016 22:20:31 +0100 Subject: [PATCH] add VertexArray.Data function --- pixelgl/vertex.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pixelgl/vertex.go b/pixelgl/vertex.go index 1f93a49..ec0d535 100644 --- a/pixelgl/vertex.go +++ b/pixelgl/vertex.go @@ -180,6 +180,17 @@ func (va *VertexArray) Draw() { 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. // // Offset is not a number of bytes, instead, it's an index in the array. -- GitLab