glDrawArrays question

Hi,

I have a question regarding using gldrawarrays in transform feedback.
Here is the code:

mFeedbackObj[1 - mDrawIdx]->bind();
gl::beginTransformFeedback( GL_POINTS );
gl::drawArrays( GL_POINTS, 2*mNumNodes, mNumNodes * mNumLines - 2 * mNumNodes );
gl::endTransformFeedback();
mFeedbackObj[1 - mDrawIdx]->unbind();

which is pretty much the same with the transform feedback sample.

And the problem is, for gl::drawArrays(GL_POINTS, startIndex, numberOfPoints);
If I put 0 as startIndex, everything is working as expected, no matter what number I put for numberOfPoints.
But if I change startIndex to some other number and reduce the numberOfPoints accordingly, something odd happens.

And here is the update shader code:

#version 330 core

#define LIMIT 0.9549296586
#define M_PI  3.1415926535

layout (location = 0) in vec3  VertexPosition;
uniform float 		  uTime;
out vec3 tfPosition;

//taken from http://www.neilmendoza.com/glsl-rotation-about-an-arbitrary-axis/
mat4 rotationMatrix(vec3 axis, float angle)
{
    float s = sin(angle);
    float c = cos(angle);
    float oc = 1.0 - c;
    return mat4(oc * axis.x * axis.x + c,           oc * axis.x * axis.y - axis.z * s,  oc * axis.z * axis.x + axis.y * s,  0.0,
                oc * axis.x * axis.y + axis.z * s,  oc * axis.y * axis.y + c,           oc * axis.y * axis.z - axis.x * s,  0.0,
                oc * axis.z * axis.x - axis.y * s,  oc * axis.y * axis.z + axis.x * s,  oc * axis.z * axis.z + c,           0.0,
                0.0,                                0.0,                                0.0,                                1.0);
}

vec3 rotateVector(vec3 vector, float angle, vec3 axis)
{
    mat4 matrix = rotationMatrix(axis, angle);
    vec4 res = matrix * vec4(vector,1.0);
    return res.xyz;
}

void main()
{
    tfPosition = rotateVector(VertexPosition,uTime,vec3(0,1,0));
}

Since the update shader only uses the current vertex position passed in to rotate it surrounds a pivot, it shouldn’t be interfered by other vertices I think.
Any thoughts? Possibilities?

And happy new year!
-seph

Can you describe what happens?

Yeah,
So here is the screenshot when things work as expected:


8 rings should rotate around the center pivot;

And this is what happens after I change the startIndex to 2*mNumNodes. If it work as expected, then there should be 6 rings rotating while the other 2 hold still. But it looks like the vertices are messed up somehow.

-seph

Ah I think I figured out why.
It looks like glDrawArrays does take the startIndex correctly but when it write into the feedback buffer it begins with 0. So in this case since I started by offsetting 2 rings then eventually all the rings will be shifted to the position of the first 2 rings.

So I guess then my question would be, is there a way to do transform feedback with only a portion of the points in the buffer?