dynamically set the stride in a glVertexAttribPointer

I was wanting to know is there any way of setting the stride in a glVertexAttribPointer with out manually counting the amount of elements the array that it has to go through to get to the next set of elements. I am assuming there is a way of doing this iam just not sure how to go about doing it. Also is there any way of doing the same for an offset if needed?

GLfloat vertices[] = {
0.5f, -0.5f, 0.0f, 1.0f, 0.0f, 0.0f,
-0.5f, -0.5f, 0.0f, 0.0f, 1.0f, 0.0f,
0.0f, 0.5f, 0.0f, 0.0f, 0.0f, 1.0f
};
For instance i have a glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 6 * sizeof(GLfloat), (GLvoid*)0);

[QUOTE=gwartney;1282299]I was wanting to know is there any way of setting the stride in a glVertexAttribPointer with out manually counting the amount of elements the array that it has to go through to get to the next set of elements.
[/QUOTE]
No.

Why? How would that even be possible?

No.

How could glVertexAttribPointer() (or any function) figure out what the offset and stride should be? You could choose almost any values for those parameters and format the data such that they would be correct.

The only actual constraint is that the stride must be non-negative. The offset cannot be negative because it’s passed as a pointer. Practically, it must be smaller than the buffer, if the data is actually being sourced from a buffer object (in the compatibility profile, it can be a pointer to client memory, so there’s know way for OpenGL to know the size of the data). The stride doesn’t even need to be smaller than the buffer (if it only contains a single vertex, the stride doesn’t matter).

Ah ok thanks for the help

Use a struct instead of an array of floats for each vertex. Then you just do sizeof (struct) and that’s your stride.

ah ok thanks