# Z rotation causing skew Android OpenGL ES 2.0

If I rotate about the X, or Y axis there is no skewing however for a pure 2D game that does not help me. When I try to rotate about the Z axis however the quad I am rendering for the sprite starts to skew until it disappears at 90 degrees appearing again shortly after a slowly resuming a quad shape. As far as I can tell I have written the code correctly, it is as I have written it before on 2D projects and it worked there I am either missing something stupid or OpenGL ES 2.0 does something different then what I expect, some excerpts of code follow:

Projection/View:

Matrix.setLookAtM(ViewMatrix, 0, 0, 0, 3, 0f, 0f, 0f, 0f, 1.0f, 0.0f);
Matrix.orthoM(ProjectMatrix, 0, -width/2, width/2, -height/2, height/2, 0 , 100);


Rotation/Scale/Translation(For in place set to identity first):

Matrix.translateM(Translation, 0, x, y, 1.0f);
Matrix.setRotateM(Rotation, 0, angle += 0.05f, 0.0f, 0.0f, 1.0f);
Matrix.scaleM(Scale, 0, 64,64,1.0f);


Multiplication of Matrices:

Matrix.multiplyMM(MVPMatrix, 0, ProjectMatrix, 0, ViewMatrix, 0);
Matrix.multiplyMM(MVPMatrix, 0, MVPMatrix, 0, Translation,0);
Matrix.multiplyMM(MVPMatrix, 0, MVPMatrix, 0, Rotation, 0)
Matrix.multiplyMM(MVPMatrix, 0, MVPMatrix, 0, Scale, 0);


Thanks for any help.

• Though I don't know too much of matrix transformations and stuff, I know you should pay attention to the order of translations/rotations. Mar 7, 2012 at 21:47
• The issue here was Matrix.multiplyMM, and using MVPMatrix as the output put and the input. In most all other libraries I used/made that would be correct. However looking closer at the specification for the function the api provided is undefined if any of the inputs or outputs overlap. Mar 8, 2012 at 1:10
• @leonmajere What Matrix library are you using for android on java? Just a curiosity. Mar 8, 2012 at 1:42
• android.opengl.Matrix developer.android.com/reference/android/opengl/Matrix.html Mar 8, 2012 at 4:32