Before drawing some objects I am modifying the modelview matrix like so

gl.glTranslatef(tX, tY, tZ);

gl.glRotatef(angle, rX, rY, 0);

which produces the result I want. However my project requires to do these matrix modifications manually.

So modifying my vertices like this gives the desired translation (I am using vertex arrays)

vertice[i] = vertice[i] + tX;

vertice[i+1] = vertice[i+1] + tY;

vertice[i+2] = vertice[i+2] + tZ;

However the rotation seems to be troublesome…

I looked up the way glRotatef modifies the matrix

http://www.opengl.org/sdk/docs/man/xhtml/glRotate.xml

So I recreated it, leaving out the Z stuff as that is 0, will return 0 within the subcalculations and therefore is not of any matter.

[A B C]

[D E F]

[G H I]

float c = (float) Math.cos(angle);

float s = (float) Math.sin(angle);

float A = rX*rX*(1-c) + c;

float B = rX*rY*(1-c);

float C = rY*s;
float D = rY*rX*(1-c);

float E = rY

*rY*(1-c) + c;

float F = -rX

*s;*

float G = -rYs;

float G = -rY

float H = rX*s;

float I = c;

Then I multiplied the current (normalized) vector [rX, rY, 0] with this matrix to create a new vector (again leaving out the Z as it is 0)

float nX = (float) (A*rX + B*rY);

float nY = (float) (D*rX + E*rY);

Now when I modify my vertices with this new vector, it does not give the same results as it would with glRotatef

vertice[i] = vertice[i] * nX;

vertice[i+1] = vertice[i+1] * nY;

I tried swapping the translations and rotations without any joy. As far as I know, no prior modifications are made to the current model matrix.

Am I overlooking something here?