admin管理员组文章数量:1355592
I need to get back a float[]
of vertices which is stored in attrList in vbo in vao.
I do:
float[] b = new float[vertexCount];
glBindVertexArray(vaoId);
long pointer;
glEnableVertexAttribArray(0);
pointer = glGetVertexAttribPointer(0, GL_VERTEX_ATTRIB_ARRAY_POINTER);
glBindBuffer(GL_ARRAY_BUFFER, (int) pointer);
glGetBufferSubData(GL_ARRAY_BUFFER, 0, b);
All data in vaos and vbos is stored correctly, I can draw things perfectly.
The problem here is that variable pointer returns 0.
What am I doing wrong?
I need to get back a float[]
of vertices which is stored in attrList in vbo in vao.
I do:
float[] b = new float[vertexCount];
glBindVertexArray(vaoId);
long pointer;
glEnableVertexAttribArray(0);
pointer = glGetVertexAttribPointer(0, GL_VERTEX_ATTRIB_ARRAY_POINTER);
glBindBuffer(GL_ARRAY_BUFFER, (int) pointer);
glGetBufferSubData(GL_ARRAY_BUFFER, 0, b);
All data in vaos and vbos is stored correctly, I can draw things perfectly.
The problem here is that variable pointer returns 0.
What am I doing wrong?
1 Answer
Reset to default 1No, your code is nonsense.
From the documentation of glGetVertexAttribPointer
:
The pointer returned is a byte offset into the data store of the buffer object that was bound to the GL_ARRAY_BUFFER target (see glBindBuffer) when the desired pointer was previously specified.
You should thus pass pointer
as the offset
parameter of your glGetBufferSubData
call. Your code treats it as the name of the VBO that was bound (because you call glBindBuffer
); if you want to retrieve that you can ask using glGetVertexAttrib(0, GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING)
. Same goes for the stride, divisor, etc.
But all of this smells like a giant XY problem: you should know the values that were used at setup time, no?
本文标签: javaHow to get data stored in VBOStack Overflow
版权声明:本文标题:java - How to get data stored in VBO - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743953692a2567752.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
b[]
around - but assuming you don't want to do that, look at:glMapBuffer
with:GL_ARRAY_BUFFER, GL_READ_ONLY
– Brett Hale Commented Mar 31 at 11:01