Jump to content
  • Advertisement
Sign in to follow this  
serious_learner07

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.

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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 this post


Link to post
Share on other sites
Quote:
Original post by JPulham
actually, 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 this post


Link to post
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!