Getting data from Vertex buffer

Started by Aisaaax, July 20, 2022, 05:54:12

Previous topic - Next topic

Aisaaax

Hello!
From what I read on Kronos, to get data back from vertex buffer one would use glGetBufferSubData().
However this function is unavailable in LWJGL (or maybe I'm doing something wrong?)

I need to very rarely retrieve vertex data of a mesh back into the CPU-space program and update it.
- It happens super-rarely, so performance is not a concern
- The mesh is procedurally generated, so there's no file stored anywhere that I can access
- I could store it in a separate array all the time, but this feels like a waste of memory for a task that happens once an hour (and realistically probably would never happen)

The idea is that I need to update the coordinates of that mesh in case the control object gets too far away from coordinate origin to preserve precision.

KaiHH

QuoteHowever this function is unavailable in LWJGL (or maybe I'm doing something wrong?)

In core OpenGL, this function was introduced with OpenGL 1.5, so it's in the GL15 class of LWJGL3:
- https://javadoc.lwjgl.org/org/lwjgl/opengl/GL15C.html#glGetBufferSubData(int,long,java.nio.ByteBuffer)

Or you can use the ARB_vertex_buffer_object extension via https://javadoc.lwjgl.org/org/lwjgl/opengl/ARBVertexBufferObject.html

Aisaaax

Quote from: KaiHH on July 20, 2022, 06:47:35
In core OpenGL, this function was introduced with OpenGL 1.5, so it's in the GL15 class of LWJGL3:
- https://javadoc.lwjgl.org/org/lwjgl/opengl/GL15C.html#glGetBufferSubData(int,long,java.nio.ByteBuffer)
Oh, I'm sorry, I actually completely forgot to mention that I'm working with OpenGL-ES, and I don't even have opengl module in my app.
Is there a way to do this in openGLES?

Edit:
glMapBufferRange seems to be the one I need.
Sorry for a stupid question, I would have found the answer if I bothered to search for ES specifically.

KaiHH

You are right, there is no glGetBufferSubData() for OpenGL ES.