title: OpenGL, translate down on y and rotate on z around ELEMENT center (on Android)
body: <p>I have an orthogonal perspective which I initialize like so:</p>
  
  <pre><code>gl.glViewport(0, 0, Constants.SCREEN_WIDTH, Constants.SCREEN_HEIGHT);   
  gl.glMatrixMode(GL10.GL_PROJECTION);    
  gl.glLoadIdentity();                    
  gl.glOrthof(0,Constants.GAME_AREA_WIDTH, Constants.GAME_AREA_HEIGHT, 0, 1, 10);
  gl.glMatrixMode(GL10.GL_MODELVIEW);     
  gl.glLoadIdentity();
  </code></pre>
  
  <p>What I want to do here is have a square start off the top of the screen (at like (x,-100,z) and the that square should descend (on y) while at the same time roate (on z). </p>
  
  <p>The square's upper-left is what I use as reference for the square's position.</p>
  
  <p>Ok, now, I think I get how to roate it around itself. I translate the thing to (-squareSize/2, -squareSize/2,z), rotate it along z, then translate back. And indeed, if I only test this rotation it works ok:</p>
  
  <pre><code>    gl.glLoadIdentity();
      angle = angle + 3;
      if(angle&gt;360) {
          angle = angle - 360;
      }
      gl.glTranslatef(xCurrent+size/2, yCurrent+size/2,0);
      gl.glRotatef(angle, 0, 0, 1);
      gl.glTranslatef(-(xCurrent+size/2), -(yCurrent+size/2),0);
  //omitted: enable client state, draw elements, disable client state.
  </code></pre>
  
  <p>With just this, no matter where I place my square (even small negative values for x and y which only make it partially show on the screen), it will rotate around its center.</p>
  
  <p>However I can't figure out how to add the downwards translation on y. If I do something like this:</p>
  
  <pre><code>    angle = angle + 3;
      if(angle&gt;360) {
          angle = angle - 360;
      }
      gl.glTranslatef(xCurrent+size/2, yCurrent+size/2,0);
      gl.glRotatef(angle, 0, 0, 1);
      gl.glTranslatef(-(xCurrent+size/2), -(yCurrent+size/2),0);
  
      yCurrent = yCurrent + realSpeed;
      if(yCurrent&gt;Constants.GAME_AREA_HEIGHT+size) {
          yCurrent=-size;
      }
      gl.glTranslatef(0f, yCurrent,0f);
  </code></pre>
  
  <p>it will only work ok if my square start at (0,0,z) - in which case it will move down and rotate around it's center.</p>
  
  <p>If however I start it at any positive or negative non 0 value for either x or y, it will still move down, but do a weird spiral motion instead of rotating agains its center.</p>