title: OpenGl Rotation around point
body: <p>My problem is that I need to rotate a white square around the center of the far left end, and no matter what I try, I cannot seem to do it. </p>
  
  <p>I need to rotate an object around <code>radius</code>, which is <code>radius</code> far from the position (<code>getPosition().x/y</code>), which i have already translated to. I need to rotate it r degrees. If it matters, I am using an orthographic (<code>glOrtho</code>) projection.</p>
  
  <p>So far this what I tried:</p>
  
  <pre><code>//Try 1
  glRotatef(r, 0, 0, 1.0f);
  glTranslatef(radius, radius, 0);
  glBegin(GL_QUADS)
  //draw here...
  
  //Try 2
  glTranslatef(-radius, -radius, 0);
  glRotatef(r, 0, 0, 1.0f);
  glTranslatef(radius, radius, 0);
  glBegin(GL_QUADS)
  //draw here...
  
  //Try 3
  glTranslatef(radius + getPosition().x, radius + getPosition().y, 0);
  glRotatef(r, 0, 0, 1.0f);
  glTranslatef(radius, radius, 0);
  glBegin(GL_QUADS)
  //draw here...
  </code></pre>
  
  <p>I have tried Googling and searching on StackOverflow <strong>numerous</strong> times, with no luck. Two of these "solutions" came from answers found on StackOverflow itself.</p>
  
  <p>All of these attempts rotate around the origin. I have also tried numerous other more nonsensical combinations, to no avail. If it matters, a little bit before this code, I translate the matrix (and don't pop it back out). I don't think this is the problem, as popping the matrix and pushing a new one back on right before any of these attempts does not fix the problem.</p>
  
  <p>Any help would be much appreciated.</p>