Will this be possible in the new OpenGL

Hi all. I have data where there many ‘z’ values for each xy. This typically happens for soil samples with chemical analysis. (ok, x,y,z, chem1, chem2, … chem9999 … )

PS. Sorry for crazy c like code, but trying to post C code is not working in certain places.
So we sort this data as

struct xy {
double x,y;
};

xy data[large_number];

and then

double chemical_reading_1[];
double chemical_reading_2[];

double chemical_reading_9999[];

I cannot see any way to use vertex buffers, to allow for this “distributed” format. I’d like to load the xy values, then each “z” property, and finally render each “surface” without having to manually looping

for i=0;i<NNNN;i++ {
glVertex x[i],y[i],chem1[i];
}

Actually, my “real” problem is more difficult because I really have

struct xyz {
double x,y,z;
}

and I’d really like to be able to program OpenGL to be access data at any offset from the beginning of a structure. So to be able to pass in the length of the structure, and the offset into it for a particular property. So

xyz *array;
double *chem7;

// and using GNU’s offsetof

short stride_xyz = sizeof xyz;
short offset_x = offsetof xyz , x;
short offset_y = offsetof xyz , y;
short stride_z = sizeof z
short offset_z = 0;

glSetXBuffer array,stride_xyz,offset_x;
glSetYBuffer array,stride_xyz,offset_y;
glSetZBuffer chem7,stride_z ,offset_z;

so

param 1 is the address of the buffer,
param 2 is the stride length bytes
param 2 is the offset for each stride bytes

Hoping for too much?

The other reason I hope for this is that I can have 10’s or 100’s of millions of points, so having to use glVertex is really slow

If the new standard can handle this, fantastic. If not can it be considered?

Finally, so many people store their data in so many different ways, if we could program OpenGL in this way, everyone would get much better performance

First, before you post something in the suggestions for OpenGL forum, you should already know whether or not it is something that GL can’t already do.

Second, it can do exactly what you ask… as long as you’re using shaders. Otherwise no.

Third, there’s only one way to get good performance: storing the data the what the hardware wants. Everything else is less optimal.

OK,

First, I’ve used OpenGL for 10 years and I cannot make it do it.

Second, everyone is saying Shaders fix everything

Third, everyone does not store their information in the format the hardware wants because that is too low level for object oriented databases.

If what I proposes was added, maybe a few percent loss of performance? That is really my choice and decision when developing a program.

Hum…

I’m not much of an expert but that should be possible, and you will need to use a vertex shader.

Create a vertex shader with 2 vertex attributes, one vec2 for the x and y, and one float for the z values.

Your xy data would be stored in one VBO and each chemical_reading would be stored in a seperate buffer.

In your vertex shader you can recombine the data into the correct format.

One issue you may have is that your storing your data as doubles. Current hardware doesn’t really like doubles, consider converting it to either floats or ints (assuming your data fits into that range).

Regards
elFarto