#define FPS 80
void plot_points(
float *o, // output raster array (w*h)
int w, // width of raster
int h, // height of raster
float *x, // input point coordinates (2*n)
int n // number of input points
)
{
// initialize the output raster
for (int i = 0; i < 2*w*h; i++)
o[i] = 0;
// accumulate the points that fall inside the raster
for (int i = 0; i < n; i++)
{
int p = x[2*i+0];
int q = x[2*i+1];
if (p >= 0 && p < w && q >= 0 && q < h)
o[w*q+p] += 1;
}
}
#include <stdlib.h>
int main(void)
{
int w = 1000;
int h = 1000;
int n = 3000000;
float *x = malloc(2*n*sizeof*x);
float *o = malloc(w*h*sizeof*o);
for (int i = 0; i < 2*n; i++)
x[i] = 1000*(rand()/(1.0+RAND_MAX));
for (int i = 0; i < FPS ; i++)
plot_points(o, w, h, x, n);
return 0;
}
// NOTE: if this program runs in less than 1 second, it means that it
// is faster than "FPS"My earlier reply has a link to how GPUs actually push pixels to the screen.
There are also some excellent blog posts on how line rendering is done:
Then, to draw something like this imgur.com/a/mXvEBzl (ADS-B data, ~10 million points iirc), you need to connect points with (antialiased) lines, where individual pixel should be blended into plot with respect of line opacity. Also, lines can be of different thickness, so it multiplies your `o[w x p+p] += 1` again.
I'm not even talking about multiple layers that are quite standard.
I use my own plotting app, it takes a lot more than just slap a bunch of points into "float *o". Try to write your own, you will figure it out pretty quickly, unless you're ok with black blobs that resemble the input data.