I won’t post my entire program here because it’s a little too long. But I have this renderer (shortened):
class OpenGLRenderer implements Renderer {
private CubicPolygon cube;
public OpenGLRenderer(Context context) {
this.context = context;
cube = new CubicPolygon();
}
public void onDrawFrame(GL10 gl) {
gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
gl.glLoadIdentity();
gl.glTranslatef(0.0f, 0.0f, -9.0f);
gl.glScalef(0.8f, 0.8f, 0.8f);
// If it's just a regular rotation
if (!numberHasBeenDrawn) {
gl.glRotatef(getXRotation(rotatingOfDOOMFire), 1, 0, 0);
gl.glRotatef(getYRotation(rotatingOfDOOMFire), 0, 1, 0);
gl.glRotatef(getZRotation(rotatingOfDOOMFire), 0, 0, 1);
}
// If there is a chosen one (number that is)
if (numberHasBeenDrawn) {
gl.glRotatef(xAnimation(number), 1, 0, 0);
gl.glRotatef(yAnimation(number), 0, 1, 0);
}
gl.glFinish();
cube.draw(gl);
}
Now what I would love to do is get the current rotation values of that cube object there in the “numberHasBeenDrawn” if statement so I can create a little smooth end animation to rotate the cube. OpenGL is probably saving all the rotation values in a handy (barely readable) matrix but after some googling I couldn’t really find anything about WHERE (just how to initially rotate an object, which I already do).
// EDIT: If you want to see more code to maybe help me, go ahead and ask, it’s not really anything secret, I can post it as well 😉
You should cache the rotation values yourself in the program somewhere. Reading state and values back from the OpenGL API is generally discouraged, and can be slow, as it breaks the pipelining that the API is built to allow (for performance reasons, to decouple the GPU from the CPU).