Solved

Can someone explain stride to me? (VertexPointer)

Posted on 2004-09-19
1
720 Views
Last Modified: 2013-12-26
void glVertexPointer(
  GLint size,
  GLenum type,
  GLsizei stride,
  const GLvoid *pointer
);

Parameters

size
    The number of coordinates per vertex. The value of size must be 2, 3, or 4.
type
    The data type of each coordinate in the array using the following symbolic constants: GL_SHORT, GL_INT, GL_FLOAT, and GL_DOUBLE.
stride
    The byte offset between consecutive vertices. When stride is zero, the vertices are tightly packed in the array.
pointer
    A pointer to the first coordinate of the first vertex in the array.

I find the definition of stride very vague. Could someone explain what it exactly means? For example, if i have an array of vertices... array { x, y, z, x, y, z, x, y, z } and the stride is set to 12 does this mean that if i call glArrayElement (1) it will draw the first set of x, y, z? (array[0], array[1], array[2])?
Or

does it mean the data is represented like this:
array { x, x, x, y, y, y, z, z, z }?

Thanks
0
Comment
Question by:zekard
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 3

Accepted Solution

by:
str_ek earned 50 total points
ID: 12103713
stride (and so named offset spacing) is used to reduce the actual need to have more than one table descrypting a "something" you just can agregate extra verticle properities, and it lets you have all info you want in just one array ! (helps a lot when it comes to manipulating)

so you may have a

x,y,z,x,y,z form
as well as
x,y,z,alpha,type,x,y,z,alpha,type,

it's an array, so the type is constat, but it's also a linear memory so you can contain data of any virtualy constat-length type between the coordinates set :) all you need to know for furher operations is the offset of every "extra info" and total length of pack descrybing a verticle :) it may be extra coords (ie texture), calculated light, or any other junk

gl is only interested in the coords, because only coords it can use, so he makes assuption, that coords come firtst (well it's just a array you can shift it a bit, and cos it's cyclic it will always look good for gl), and lets you tell how many of array units ( this is also up to you) is he to skip each time he traces next vertice

co the cycle ( totla verticle description length) is
(stride+size)*sizeof(type) :)

got it?
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As game developers, we quickly learn that Artificial Intelligence (AI) doesn’t need to be so tough.  To reference Space Ghost: “Moltar, I have a giant brain that is able to reduce any complex machine into a simple yes or no answer. (http://www.youtu…
Recently, in one of the tech-blogs I usually read, I saw a post about the best-selling video games through history. The first place in the list is for the classic, extremely addictive Tetris. Well, a long time ago, in a galaxy far far away, I was…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question