I want to change vertex positions when key pressed. I use glMapBuffer to get buffer, but it always returns null. This is the code:
Creating vertex buffer:
FloatBuffer verticesBuffer = FloatBuffer.allocate(vertices.length * 8);
for (int i = 0; i < vertices.length; i++) {
verticesBuffer.put(vertices[i].position.x);
verticesBuffer.put(vertices[i].position.y);
verticesBuffer.put(vertices[i].position.z);
verticesBuffer.put(vertices[i].texCoord.x);
verticesBuffer.put(vertices[i].texCoord.y);
verticesBuffer.put(vertices[i].normal.x);
verticesBuffer.put(vertices[i].normal.y);
verticesBuffer.put(vertices[i].normal.z);
}
verticesBuffer.flip();
gl.glGenBuffers(1, VBOVertices, 0);
gl.glBindBuffer(gl.GL_ARRAY_BUFFER, VBOVertices[0]);
gl.glBufferData(gl.GL_ARRAY_BUFFER, verticesBuffer.capacity() * 4, verticesBuffer, gl.GL_DYNAMIC_DRAW);
Getting the buffer:
gl.glBindBuffer(gl.GL_ARRAY_BUFFER, VBOVertices[0]);
ByteBuffer verticesByteBuffer = gl.glMapBuffer(gl.GL_ARRAY_BUFFER, gl.GL_WRITE_ONLY); //this is always null
gl.glUnmapBuffer(gl.GL_ARRAY_BUFFER);