Hello Guest

Getting data from Vertex buffer

  • 3 Replies
  • 1608 Views
Getting data from Vertex buffer
« on: July 20, 2022, 05:54:12 »
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.

*

Offline KaiHH

  • ****
  • 334
Re: Getting data from Vertex buffer
« Reply #1 on: July 20, 2022, 06:47:35 »
Quote
However 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

Re: Getting data from Vertex buffer
« Reply #2 on: July 20, 2022, 07:08:11 »
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.
« Last Edit: July 20, 2022, 07:11:45 by Aisaaax »

*

Offline KaiHH

  • ****
  • 334
Re: Getting data from Vertex buffer
« Reply #3 on: July 20, 2022, 07:24:56 »
You are right, there is no glGetBufferSubData() for OpenGL ES.