title: glRotatef is backing to central position
body: <p>I'm having some issues with glRotateF. The problem is the following:</p>
  
  <p>i'm drawing 3 lines that represent a Cartesian coordinate system, they represent the point of view of a camera.</p>
  
  <p>This camera can rotate its point of view. When it rotates, it sends a message with the angles and the axis that had rotated.</p>
  
  <p>My app gets this message and sends it to a method, this method gets the axis that was rotated and its angle and sends it to this method:</p>
  
  <p>So far everything is working, the problem starts after this.</p>
  
  <p>if I send a message to rotate the angle X on any angle and angle Z on any angle too, it just rotates the z axis.</p>
  
  <p>In Debugging I noticed that first it rotated the X angle in the given angle, but when it rotates the Z in the angle, it goes back to the original position and then it rotates Z, losing the X's rotation.
  Like this example:</p>
  
  <p>Initial position:</p>
  
  <p><a href="https://i.stack.imgur.com/ATfvL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ATfvL.png" alt="Normal Coordinate System"></a></p>
  
  <p>rotate X on 90º:</p>
  
  <p><a href="https://i.stack.imgur.com/SN4Y6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SN4Y6.png" alt="Rotate 90 on X"></a></p>
  
  <p>rotate Z on 90º (What should be):</p>
  
  <p><a href="https://i.stack.imgur.com/b6YBs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/b6YBs.png" alt="Rotate 90 on Z right"></a></p>
  
  <p>rotate Z on 90º (What is really happening):</p>
  
  <p><a href="https://i.stack.imgur.com/IJFoL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IJFoL.png" alt="Wrong Z rotate"></a></p>
  
  <p>What i want is rotate x and then z without lose x rotation.</p>
  
  <p>This is how i call to rotate an axis:</p>
  
  <pre><code>openGl.rotateX((float) x);
  openGl.rotateZ((float) z);
  </code></pre>
  
  <p>The method rotateX and rotateZ</p>
  
  <pre><code>public void rotateX(float grau) {
      mCubeRotation = grau;
      eixoX = 1.0f;
      eixoY = 0.0f;
      eixoZ = 0.0f;
      surfaceView.requestRender(); // line to call onDrawFrame
  }
  
  public void rotateZ(float grau) {
      mCubeRotation = grau;
      eixoX = 0.0f;
      eixoY = 0.0f;
      eixoZ = 1.0f;
      surfaceView.requestRender(); // line to call onDrawFrame
  }
  </code></pre>
  
  <p>This is the code of rotation:</p>
  
  <pre><code>@Override
  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, -8.0f);
  
      // When i rotate x eixoX equal 1 and the other axis is 0.
      // When i rotate z eixoZ equal 1 and the other axis is 0.
      gl.glRotatef(mCubeRotation, eixoX, eixoY, eixoZ);
  
      mCube.draw(gl);
  
      gl.glLoadIdentity();
  
      lock = false;
  }
  </code></pre>
  
  <p>if someone help me,  I will appreciate.</p>