title: Why is my glutWireCube not placed in origin?
body: <p>I have the following OpenGL code in the display function:</p>
  
  <pre><code>glLoadIdentity();
  gluLookAt(eyex, eyey, eyez, atx, aty, atz, upx, upy, upz);
  // called as: gluLookAt(20, 5, 5, -20, 5, 5, 0, 1, 0);
  
  axis();
  glutWireCube (1.);
  
  glFlush ();
  </code></pre>
  
  <p><code>axis()</code> draws lines from (0,0,0) to (10,0,0), (0,10,0) and (0,10,0), plus a line from (1,0,0) to (1,3,0).</p>
  
  <p>My reshape function contains the following:</p>
  
  <pre><code>glViewport (0, 0, (GLsizei) w, (GLsizei) h);
  glMatrixMode (GL_PROJECTION);
  glLoadIdentity ();
  gluPerspective(45.0, (GLsizei) w / (GLsizei) h, 1.0, 100.0);
  glMatrixMode (GL_MODELVIEW);
  </code></pre>
  
  <p>This image shows the result of running the program with <code>1.</code> as the argument to <code>glutWireCube</code>:</p>
  
  <p><img src="https://i.imgur.com/91wdN.png" alt="glutWireCube(1.)"></p>
  
  <p>As you can see, the cube isn't centered around (0,0,0) as the documentation says it should be:</p>
  
  <blockquote>
    <p>The cube is centered at the modeling
    coordinates origin (...) <a href="http://www.opengl.org/resources/libraries/glut/spec3/node82.html" rel="nofollow noreferrer">(source)</a></p>
  </blockquote>
  
  <p>If I run the program with <code>5.</code> as the argument, the cube is displaced even further:</p>
  
  <p><img src="https://i.imgur.com/igkHk.png" alt="glutWireCube(5.)"></p>
  
  <p>Why is that, and how do I place the cubes around (0,0,0)?</p>
  
  <p><strong>FURTHER INFORMATION</strong></p>
  
  <p>It doesn't matter if I switch the order of <code>axis()</code> and <code>glutWireCube</code>. Surrounding <code>axis()</code> with <code>glPushMatrix()</code> and <code>glPopMatrix()</code> doesn't fix it either.</p>
  
  <p><strong>SOLUTION</strong></p>
  
  <p>I modified <code>gluPerspective</code> to start looking further away from the camera, and now the Z-buffering works properly, so it is clear that the cubes are placed around the origin.</p>