I currently have a struct array which holds all of the data required for a point of a triangle.
struct TriangleSurfaceArray{
float u, v, nx, ny, nz, x, y, n
};
After putting the data into the struct array. I cnn’t figure out how to make glInterleavedArray accept the struct as an array and parse the data correctly.
Using a direct rendering approach this code works fine:
for a better example heres what the correct rendering looks like via the direct render method in the first post. Direct Render
and heres one using the interleaved array code above. interleaved struct
I think you should try
glInterleavedArrays(GL_T2F_N3F_V3F, 0, TriangleSurfaceStructUV);
because the second parameter (stride) is the size of unuseful data between array elements… At least I use the function this way in my program…
What is the “- 8 * sizeof(float)” for? Surely you just want a stride of sizeof(TriangleSurfaceArray).
Remember that the stride is the offset between the BEGINNING of two successive elements. Stride=0 is a special case, which means that the arrays are tightly packed. All other values give the distance between the beginnings of vertices.
Originally posted by bakery2k: Remember that the stride is the offset between the BEGINNING of two successive elements. Stride=0 is a special case, which means that the arrays are tightly packed. All other values give the distance between the beginnings of vertices.