# stride and Interleaved arrays

This topic is 3629 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I am trying to render a terrain mesh. I have 2 questions 1.In glVertexpointer API, there is a parameter called stride. What is its use. When I specify 0, it is ok. But others does not work. Why? 2. How does glInterleaved works. Is it necessary to use. Can I do away with this.

##### Share on other sites
The stride usually means what is the size of an single vertex. for example if you have
struct Vertex
{
float x,y,z;
}

Then your stride would be 12 bytes. or you can simply use sizeof(Vertex)

##### Share on other sites
actually, stride is the space between vertices.
so if you packed the Vertex like this:
struct Point{    float x, y, z;}struct Normal{    float x, y, z;}struct Vertex{    Point pos;    Normal norm;    ...}Vertex vtx;

then the vertex pointer would be 0 and stride would be sizeof(Vertex) - sizeof(Point)
normal pointer would be 12 and stride would be sizeof(Vertex) - sizeof(Normal)

etc., etc., etc.

##### Share on other sites
Quote:
 Original post by JPulhamactually, stride is the space between vertices.so if you packed the Vertex like this:*** Source Snippet Removed ***then the vertex pointer would be 0 and stride would be sizeof(Vertex) - sizeof(Point)normal pointer would be 12 and stride would be sizeof(Vertex) - sizeof(Normal)etc., etc., etc.

It's not. The stride is the distance from the start of one vertex to the start of the next. A stride of zero is a special case to mean a tightly packed attribute array.

##### Share on other sites
I believe stride is used if there is empty space between the vertex data that you are trying to use. If you loaded the array with your vertex data one right after the other then just use 0 which means the data is coming with no breaks.

1. 1
Rutin
23
2. 2
3. 3
JoeJ
20
4. 4
5. 5

• 29
• 40
• 23
• 13
• 13
• ### Forum Statistics

• Total Topics
631739
• Total Posts
3001957
×