So, I have a system (using OpenGL 4.x) where I get a stream of dots (potentially with color and / or normal) from an external source. And I need to draw these points as GL_POINTS using custom switchable shaders for coloring (color can be generated using procedures or derived from vertex color or normal direction).
The flow consists of receiving a group of points (with a normal or color or without it) of an arbitrary count (typical from 1 to 70 thousand points) over a fairly regular interval (from 4 to 10 Hz), I need to add these points to my current points and draw all the points received so far.
I'm sure my vertex type will not change, they tell me at the beginning of the streaming that you can expect, so I either use a striped vertex with: pos + normal + color, pos + normal, pos + color, or just pos.
My current solution is to select alternating vertex VBOs (with surrounding VAOs) of the corresponding vertex type in the configuration file indicated by the maximum number of vertices (highlighted by the DYNAMIC hint).
As I enter new points, I populate my current unfilled VBO with glBufferSubData. I keep an account (activePoints) of how many vertices the VBO VBO border currently has and use glBufferSubData to fill the range starting with activePoints if my current update group has more vertices than can fit in my border buffer (since I limit the number of vertices on VBO), then I assign a new VBO and fill in the range starting from 0 and ending with the number of remaining points in my update group (not added to the last buffer), if I still have remaining points, I do it again and again. It is rare that an update group spans over 2 buffers.
When rendering, I displayed all of my VBOs (-1) using glDrawArrays (m_DrawMode, 0, numVertices), where numVertices is equal to the maximum size allowed by the buffer, and my border buffer with glDrawArrays (m_DrawMode, startElem, numElems) don't mind that completely filled with real peaks.
Of course, at some point I will have more points than online, so I have an LRU mechanism that overrides the oldest (according to LRU alg) VBOs sets as needed.
Is there a better way to do this? Buffer orphanage? Stream hint? Map vs SubData? Something else?
The second problem is that I am now being asked to delete points (at irregular intervals), starting from 10 to 2000 at a time. But these points are irregularly spaced in the order in which I received them initially. I can find out which offsets in which they are currently going out, but are more scattered than the range. I “deleted them”, finding their offsets in the desired buffers and one after the other, calling glBufferSubData with a range of 1 (which is rare in their buffer) and changing their place somewhere far away, they will never be visible. In the end, I think the buffers should be removed from this flushing of the delete request, but at the moment I do not.
What would be the best way to handle this?