title: How do I correctly draw 3D axis in OpenGL?
body: <p>I am trying to draw the 3D axis. I have also a cone which is rotating around its vertex and I would want the axis starting from there.</p>
  <p>Here I have my function to draw the cone and I wrote the functions to draw the axis after <code>gluLookAt</code>:</p>
  <pre class="lang-cpp prettyprint-override"><code>GLfloat xRotated, yRotated, zRotated;
  // Cone
  GLdouble base=0.5;
  GLdouble height=1.3;
  GLint slices =20;
  GLint stacks =20;
  std::vector&lt;std::array&lt;GLfloat, 3&gt;&gt; data;
  
  
      void displayCone(void)
      {
          // set matrix mode
          glMatrixMode(GL_MODELVIEW);
          // clear model view matrix
          glLoadIdentity();
          // multiply view matrix to current matrix
          gluLookAt(0,2.,0.,0.,0.,-4.5,0,1,0); // &lt;----------------------- add
          
          // ******
          glPushMatrix();
       
          glLoadIdentity();
          
          glTranslatef(0.0, 0.0, -4.5);
  
          glBegin(GL_LINES);
  
          glColor3f (1.0, 1.0, 0.0);
          glVertex3f(0.0, 0.0, 0.0);
          glVertex3f(2.0, 0.0, 0.0);
          
          glColor3f (1.0, 1.0, 0.0);
          glVertex3f(0.0, 0.0, 0.0);
          glVertex3f(0.0, 2.0, 0.0);
         
          glColor3f (1.0, 1.0, 0.0);
          glVertex3f(0.0, 0.0, 0.0);
          glVertex3f(0.0, 0.0, 2.0);
          glEnd();
  
          glPopMatrix();
          
  // ******
          // clear the drawing buffer.
          glClear(GL_COLOR_BUFFER_BIT);
          
          // traslate the draw by z = -4.0
          // Note this when you decrease z like -8.0 the drawing will looks far , or smaller.
          glTranslatef(0.0,0.0,-4.5);
          // Red color used to draw.
          glColor3f(0.8, 0.2, 0.1);
          // changing in transformation matrix.
          // rotation about X axis
          glRotatef(xRotated,1.0,0.0,0.0);
          // rotation about Y axis
          glRotatef(yRotated,0.0,1.0,0.0);
          // rotation about Z axis
          glRotatef(zRotated,0.0,0.0,1.0);
          
          // scaling transfomation
          glScalef(1.0,1.0,1.0);
          // built-in (glut library) function , draw you a Cone.
          
          // move the peak of the cone to the origin
          glTranslatef(0.0, 0.0, -height);
          
          glutSolidCone(base,height,slices,stacks);
          // Flush buffers to screen
          // gluLookAt(3,3,3,0,0,-4.5,0,1,0); &lt;----------------------- delete
          
          
  
          glFlush();
          // sawp buffers called because we are using double buffering
          // glutSwapBuffers();
      }
  
  </code></pre>
  <p>I thought to draw the 3D axis in this way but I am making some mistakes.
  What am I missing?</p>