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