Possible Duplicate:
Is Google’s Android OpenGL tutorial teaching incorrect linear algebra?
Learning OpenGL ES 2.0 on Android. Using Emulator, running Android 4.1.
Copied and pasted snippets from Android Developer Site / OpenGL
Updated onDrawFrame
method. Pasted below.
Added Matrix.setIdentityM(mRotationMatrix, 0)
since it's was a Null Matrix.
Changed mAngle to angle (line 16).
public void onDrawFrame(GL10 unused) {
// Redraw background color
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
// Set the camera position (View matrix)
Matrix.setLookAtM(mVMatrix, 0, 0, 0, -3, 0f, 0f, 0f, 0f, 1.0f, 0.0f);
// Calculate the projection and view transformation
Matrix.multiplyMM(mMVPMatrix, 0, mProjMatrix, 0, mVMatrix, 0);
// Create a rotation transformation for the triangle
long time = SystemClock.uptimeMillis() % 4000L;
float angle = 0.090f * ((int) time);
Matrix.setIdentityM(mRotationMatrix, 0); //added
Matrix.setRotateM(mRotationMatrix, 0, angle, 0, 0, 1.0f); //changed
// Combine the rotation matrix with the projection and camera view
Matrix.multiplyMM(mMVPMatrix, 0, mRotationMatrix, 0, mMVPMatrix, 0);
// Draw shape
mTriangle.draw(mMVPMatrix);
}
And Commented out setRenderMode(RENDERMODE_WHEN_DIRTY);
Yet the Triangle drawn did not rotated. Where did I go wrong?