title: Earth tilt openGL c++
body: <p>I'm working on the solar system and I'm trying to get the planet Earth to rotate properly around the Sun. I can get it to orbit and rotate on its axis, but I can't get it to be tilted in the right angle, as seen in the picture below:
  <img src="https://i.stack.imgur.com/clIhi.png" alt="enter image description here"></p>
  
  <p>I can tilt my planet, but it loos like this when it goes around (it doesn't "face" the same direction)</p>
  
  <p><img src="https://i.stack.imgur.com/qCxMb.png" alt="enter image description here">
   Any ideas what I could do? Here is my code:</p>
  
  <pre><code>glMatrixMode(GL_MODELVIEW);
  glPushMatrix();
  //sun
  glMaterialAmbientAndDiffuse(GLMaterialEnums::FRONT,GLColor&lt;GLfloat,4&gt;(1.5f,1.0f,0.0f));
  glTranslate(0.0f, 0.0f, 0.0f);
  glRotate(0.0, 0.0, 0.0, 00.0);
  drawEllipsoid(10.0, 1.0, 4, 4);
  
  //Earth
  glRotate(orbit, 0.0, 0.0, 1.0);
  glTranslate(30.0, 0.0, 0.0);
  glPushMatrix();
  glMaterialAmbientAndDiffuse(GLMaterialEnums::FRONT,GLColor&lt;GLfloat,4&gt;(0.5f,10.5f,10.5f));
  glRotatef(110,0.0,23.0,110.0f); 
  glRotatef(orbit2, 0.0f, 0.0f,1.0f);
  drawPlanetGrid(5, 1, 4, 4, 1);
  
  glRotate(30.0, 0.0,0.0,0.0);
  glTranslate(orbit2, 0.0, 0.0);
  glPopMatrix();
  orbit += .2;
  
  if (orbit &gt; 360)    
  {
  orbit = 0;
  }
  orbit2 += 6.5;
  if (orbit2 &gt; 360)
  {
  orbit2 = 0;
  }
  </code></pre>
  
  <p>Sorry the code is not commented. I am just experimenting with it.</p>