user1784182
user1784182

Reputation: 31

JOGL - Low performence after calling glMapBuffer on large array buffer

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

Answers (1)

Related Questions