0

My current implementation of removing vertices from the buffer is by copying the portions of the buffer before and after the section of vertices I want to remove, into a new buffer.

However this process becomes very slow when the buffer size increases.

So is there a way to just remove the vertices and have the vertices after them take their place in the buffer?

Wail3Y
  • 33
  • 4
  • 1
    How do you draw the vertices in the VBO? If it's a collection of separate primitives (`GL_TRIANGLES`/`GL_LINES`/`GL_POINTS`) and the order doesn't matter, you could overwrite the primitive that needs to be removed with the last primitive, and then draw one less primitive. This won't actually free any memory, but it should be faster. Also, why do you need to remove vertices from a VBO? What problem are you trying to solve? – HolyBlackCat May 16 '20 at 14:32
  • @Rabbid76: That would just replace the problem with the same problem in the index buffer. – Nicol Bolas May 16 '20 at 14:48
  • 2
    I noticed that you use python, do you create the buffer and copy it by yourself ? Python is really inefficient – Erwan Daniel May 16 '20 at 15:31
  • @HolyBlackCat Im trying to keep the memory usage down so I dont think your solution is right for me. Im actually trying to have objects added removed based on user input so thats why I need to remove the vertices. – Wail3Y May 17 '20 at 11:47
  • 1
    @ErwanDaniel I'm using glCopyBufferSubData to copy sections of the buffer. I heard this is better than just recreating the buffer because the copying is done on the graphics card without talking to the CPU – Wail3Y May 17 '20 at 11:49
  • @TotallyARealName Yes this method is faster ! To answer your first question. No you can't "strip" your buffer. I could give you an advice if are clearer with what you want to achieve. Why do you try to remove some vertices ? – Erwan Daniel May 18 '20 at 16:05
  • @ErwanDaniel I'm basically trying to make a voxel world so I need the user to be able to add and remove blocks at will. That's why I'd like to be able to remove vertices from the buffer. My buffer size is already fixed and I'm trying to keep memory usage down so just overwriting the vertices with NULL is not ideal for me. – Wail3Y May 19 '20 at 08:30
  • Ok now I got it. In a voxel world you usually don't want to have one big buffer with all your vertices. You usually have small chunks that are regenerated when a modification happens. Regenerating one chunk shouldn't be expensive, you could anyway use a double buffer to avoid the problem. – Erwan Daniel May 19 '20 at 11:44

0 Answers0