title: Rotating a 2D texture in OpenGL
body: <p>I want to rotate a 2D image about its center point in OpenGL.</p>
  
  <p>Here is my current code:</p>
  
  <pre><code>void Plane::draw() {
  
  glEnable(GL_TEXTURE_2D);
  
      glBindTexture(GL_TEXTURE_2D, plane_image);                
  
      glBegin (GL_QUADS);
      glTexCoord2f (0.0, 1.0);
      glVertex2f (pos.x-6.0, pos.y+6.0);
      glTexCoord2f (1.0, 1.0);
      glVertex2f (pos.x+6.0, pos.y+6.0);
      glTexCoord2f (1.0, 0.0);
      glVertex2f (pos.x+6.0, pos.y-6.0);
      glTexCoord2f (0.0, 0.0);
      glVertex2f (pos.x-6.0, pos.y-6.0);
      glEnd ();
  
  glDisable(GL_TEXTURE_2D);
  }
  </code></pre>
  
  <p>I had to start the quad centered at the origin and then translate it +x,+y. The translation and rotation should go before the quad is created. Thanks to BWG and Skyler!</p>
  
  <p>Solution:</p>
  
  <pre><code>glEnable(GL_TEXTURE_2D);
  glBindTexture(GL_TEXTURE_2D, plane_image);
  
  glMatrixMode(GL_MODELVIEW); 
  glPushMatrix();
  
      glTranslatef(pos.x,pos.y,0); 
      glRotatef(45,0,0,1);
  
      glBegin (GL_QUADS);
      glTexCoord2f (0.0, 1.0);
      glVertex2f (-6.0, 6.0);
      glTexCoord2f (1.0, 1.0);
      glVertex2f (6.0, 6.0);
      glTexCoord2f (1.0, 0.0);
      glVertex2f (6.0, -6.0);
      glTexCoord2f (0.0, 0.0);
      glVertex2f (-6.0, -6.0);
      glEnd ();
  
  
  glPopMatrix();
  
  glDisable(GL_TEXTURE_2D);
  </code></pre>