Reputation: 31
I've got a strange problem, I want to update array buffer which contains about half a million elements (vertices), so I call glMapBuffer(...)
, do some operations on some elements and call glUnmapBuffer(...)
, but since then my program slows down even though I do this operations once in awhile.
Here is the code
gl.glBindBuffer(gl.GL_ARRAY_BUFFER, VBOVertices[0]);
ByteBuffer verticesByteBuffer = gl.glMapBuffer(gl.GL_ARRAY_BUFFER, gl.GL_WRITE_ONLY);
FloatBuffer verticesBuffer = verticesByteBuffer.asFloatBuffer();
for(int i=0;i<verticesToBeChanged.size();i++) {
int vertexId = verticesToBeChanged.get(i);
verticesBuffer.position(vertexId*8);
verticesBuffer.put(vertices[vertexId].position.x);
verticesBuffer.put(vertices[vertexId].position.y);
verticesBuffer.put(vertices[vertexId].position.z);
}
gl.glUnmapBuffer(gl.GL_ARRAY_BUFFER);
Am I doing something wrong or this is how it works for large data sets?
I can't use glMapBufferRange(...)
method due to it doesn't exist in JOGL.
Upvotes: 0
Views: 480
Reputation: 4066
glMapBufferRange exists in JOGL 2: http://jogamp.org/deployment/jogamp-next/javadoc/jogl/javadoc/javax/media/opengl/GL.html#glMapBufferRange(int,%20long,%20long,%20int)
Upvotes: 1