Showing subset of currently rendered objects

I have a scene in which I have a bunch of point sprites rendered (~50k), and I have lines connecting these point sprites. Currently the lines are compiled to a GL list.

In my app, the user can apply some functions that hide some of the point sprites (no new ones are added, just a subset of the original are being shown). For the ones that are filtered out, I don’t want to show the lines between them.

Is there a way I can filter out some of those lines, without recreating the whole list? This can happen frequently, so I don’t want to be recreating the list of lines every time.


Maybe you can use the geometry shader to filter what lines shall be visible?

Thanks. I’m still a bit of an OGL beginner, so I’ll look into that and see how it applies here…

Alternatively: get rid of the display list and instead use a VBO for vertex data and another buffer object for the index. When the set of visible objects changes create a new index and upload it.

I’m not sure I follow the part about creating another buffer object for the index. Are you suggesting creating a buffer that has the indices of the objects that need to be drawn? Then just update that and redraw those indices?

Well, OpenGL does not operate at the level of what one usually thinks of as “objects”, it only knows it’s rendering primitives (points, lines, triangles). So for example a line between two points requires two indices (of the start and end point). But other than that, yes, the idea is to only change the contents of the buffer to contain only those indices that you need to draw.

Actually, looking back at your original problem description: if the set of lines to draw only changes on user input (i.e. < 1 per frame), just rebuilding the list should not be so bad either.

Thanks for the correction in terminology - I did mean primitives.

In general, it will be less than once per frame, though we have some cases where it could be slightly more. I will just start with rebuilding the list and measure performance first, then go from there.

Appreciate the input.