stride=8bytes(one float has 4bytes and there are two in the T variable);
Why doesn´t this work?
The problem:
If I declare the vertex struct without the texcoord and thet stride=0 then all works perfectly.
But if I include the texcoord and set stride=8 like mentioned above, the drawing-procces later(with gldrawelements) produces only some weird(randomly appearing) lines!
Stride is the distance from the beginning of one entity, to the begginging of the following entity. In your case the stride would be sizeof(vertex), or 5*sizeof(float).
Had a look in MSVC 6 help about stride, and it said: The byte offset between consecutive vertices. When stride is zero, the vertices are tightly packed in the array.
Offset is generally something you add to a value to get to the next entity. But I agree, the text itself you posted wasn’t too informative .
Sorry I have a question again! :
I added a glTexCoordPointer now:
glTextCoordPointer(2,GL_FLOAT,sizeof(vertex),
Vertices+12) //I add 12 here,cause the first texcoord in the array is 3 floats after the beggining of the array.
The Texcoords give very false results if I throw them tightly packed in an extra array I don´t get the problem.Why?
Try to call glTexCoordPointer with last argument like this: (or similar): &Vertices->T[0], this will give you the exact adress to the texcoords, even if you change the structure later.
I don’t see the problem though, the texcoords should start 12 bytes later.
Gorg: I think you have missunderstood what stride is. Stride is not the about of bytes between two elements, but the mount of bytes from the beginning of one element to the beginning of the following element. If you pass a zero as stride, it means they are tightly packed. If you have an array of floats, which contains vertices like this, x1,y1,z1,x2,y2,z2… and so on, you can set stride to either zero (as tightly packed), or 12 (3 floats*4 bytes each from the beginning of vertex one to the beginning of vertex two).
That sounds strange to me,how does OpenGl know if I want to specify the offset between the beginning of the struct to the beginning of the next one ore the offset BETWEEN to structs,if I pass a stride value?
Esay, you CAN’T pass the amount of bytes between. As simple as that. Stride==0 is just a special case for thightly packed elements. Usefull if you know you are always going to pack them tightly, no need to mess with bytes then.