Originally Posted by
psychopath
1) Recalculate the vertices using a C version of the GLSL rotate function above, and then modify the buffer data in video memory. Major and maybe insurmountable drawback: you then have to recalculate all the normals, and modify those in the buffer too. Advantage: it could be done once, rather than every frame. However, this would mean using the CPU to perform the calculations.
If I can just rotate the normal using the same algorithm, then it won't be so hard, but this did not work in the shader, so I haven't tried it outside of that yet.
Like, OMG, it worked. Whew! I needed some encouragement here.
So now I can do rotation and transformation on the video buffer data without having to call any standard functions, before the shaders are executed.
Code:
void rotate (glThing *obj, float rads, int a, int b) {
int i;
float x, z, cs = cos(rads), sn = sin(rads);
for (i=0; i<obj->len; i+=3) {
x = obj->data[i+a];
z = obj->data[i+b];
obj->data[i+a] = x*cs - z*sn;
obj->data[i+b] = x*sn + z*cs;
}
glBindBuffer(GL_ARRAY_BUFFER, obj->VBO);
glBufferSubData(GL_ARRAY_BUFFER,0,obj->len*sizeof(GLfloat),obj->data);
glBindBuffer(GL_ARRAY_BUFFER, 0);
}