My problem is that the model is not rotating about any recognizable z coordinate. I expect it to rotate about z = ctrz.
Since my data is in a linked list instead of an array, I built the VBO using
i = 0
glBindBuffer(GL_ARRAY_BUFFER, vbobuffers[0]);
gdata = (GLfloat*) glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY);
while(data != NULL){
gdata[i] = data->x;
gdata[i+1] = data->y;
gdata[i+2] = data->z;
i += 3;
data = data->next;
}
glUnmapBuffer(GL_ARRAY_BUFFER);
then, in the mouse move callback function (dx & dy are the distances the mouse has been dragged)
glColor3fv(color[32]);
glTranslatef(ctrx, ctry, ctrz);
glRotatef((theta -90dx/WindowWidth), 0.0, 1.0, 0.0);
glRotatef((phi -90dy/WindowHeight), 1.0, 0.0, 0.0);
glBindBuffer(GL_ARRAY_BUFFER,vbobuffers[i]);
glEnableClientState(GL_VERTEX_ARRAY);
glDrawArrays(GL_POINTS, 0, cardcount[GRID]);
glDisableClientState(GL_VERTEX_ARRAY);
glRotatef(-(phi -90dy/WindowHeight), 1.0, 0.0, 0.0);
glRotatef(-(theta -90dx/WindowWidth), 0.0, 1.0, 0.0);
glTranslatef(-ctrx, -ctry, -ctrz);
This scheme works perfectly when I am panning instead of rotating. It also works perfectly if i’m writing between glBegin() and glEnd().