I'm writing a program in C++ that acquires 4 dimensional points data over a UDP socket and then plots the data in 6 separate 2D scatter plots. For example if we name the dimensions: A,B,C,D the six 2d plots would be AxB, AxC, AxD, BxC, BxD, and CxD. Over the course of a few hours the program accrues ~50K points.
Currently I plot each point once, using immediate mode. I don't clear the buffer between draw calls so previously plotted points persist until the buffer is cleared. I'm not happy with this method as immediate mode is slow and deprecated. When I have to clear the buffer, as when a window re-sizes, I lose all previously plotted data. I'd like to come up with a solution that allows data persistence after the buffer is cleared. Additionally it would be nice if the plot could be easily scaled with window re-sizes as well.
I've thought about maintaining a vertex array (with 2 dimensions) for each coordinate system but that would require 6 separate arrays and require 3 times the memory of maintaining an array with all 4 dimensions.
Am I thinking about this in the right way? What is the proper solution to this problem?
The end goal is to have an application that displays the data as close to real-time as possible.
Edit Would it be possible to continue plotting the points one by one as they come in, and when I need to resize the screen grab an image of the screen and then display a resized version of that image?
Using Vertex buffer Objects can increase speed rendering, because the geometry to draw can be stored directly in the graphic card memory. However, in your case, if the data always changes, I cannot tell you if this method will be faster than immediate mode because you may have to reconstruct the Vertex Array Object each time the data change. If you only add points, maybe you can make multiple VBOs to group points, and render the last received points using immediate mode until you can create a new group. For instance, if you received 100054 points, maybe you can make 10 groups of 10000 points and render the last 54 points in immediate mode.
Concerning the memory problem, I think it might be possible to store in the graphic card vertexes with 4 elements - then you could use different vertex shaders which select which components of your vertex to use as rendering coordinates. Using this technique, memory usage would only be twice what you received: one for you received data, and one for the vertex buffer object.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With