PDA

View Full Version : Loading Data into Unform Struct Array



Husted
03-02-2007, 11:40 AM
I've implemented geometry instacing and are trying to load instance data into vertex uniforms as efficient as possible.

Each vertex contains an index pointing to the instance that it belongs to, and the vertex shader reconstruct the vertex position etc using instance specific data specified in an array of instance data.

The instance specific data looks like:


uniform struct instanceData[64] {
vec3 offset;
vec3 size;
// etc
};
I have a corresponding structure in my C++ program, but how do I load data into this array? It seems that I'm only able to load data into each struct attribute separately using glUniform3fv - but this requires splitting the struct on the client side (As there is no stride parameter in glUniform3fv).

Is there something I'm missing, or is it really not possible to load data into a struct using a single glCall, or even a single glCall for each attribute in the struct without splitting the struct on the client side?

So far I've insured that each instance data attribute is a vec3, and loaded the data using a single glUniform3fv call - but I'm hoping that there is a better way which let's me keep my struct.

Overmind
03-02-2007, 01:03 PM
Please don't post in more than one forum.

You already got an answer in the advanced forum.