title: OpenGL Drawing Axis in Corner
body: <p>I've been searching on how to draw an Indicator-Axis in my OpenGL scene. The project's nested in a Qt OpenGL widget, but I think the problem is independent of Qt.</p>
  
  <p>I have found on here and forums from years ago that suggest storing the viewport and data, loading new ones for the botttom corner, apply my rotations and draw, then restore the matrices. This seems the most beneficial to me, but I'm guessing I'm still missing some critical info in my OpenGL knowledge.</p>
  
  <p>For now I just have it drawing a red line from -x to x, so I expected to have a red square in the bottom left of the screen:</p>
  
  <pre><code>void GLWidget::drawAxis()
  {
      float tempPro[16];
      float tempMod[16];
      glGetFloatv(GL_PROJECTION_MATRIX, &amp;tempPro[0]);
      glGetFloatv(GL_MODELVIEW_MATRIX, &amp;tempMod[0]);
  
      glViewport(0, 0, 50, 50);
      glMatrixMode(GL_PROJECTION);
      glLoadIdentity();
      gluPerspective(45.0f, 1.0f, 0.1f, 20.0f);
      glMatrixMode(GL_MODELVIEW);
      glLoadIdentity();
  
      glPushMatrix();
      glBegin(GL_LINES);
          glColor3f(1.0f, 0.0f, 0.0f);
          glEnable( GL_LINE_SMOOTH );
          glLineWidth( 1.5 );
          glVertex3f(-1000, 0, 0);
          glVertex3f(1000, 0, 0);
      glEnd();
      glPopMatrix();
  
      glViewport(0, 0, 960, 600);
      glMatrixMode(GL_PROJECTION);
      glLoadMatrixf(tempPro);
      gluPerspective(45.0f, (960.0/600.0), 0.1f, 400.0f);
      glMatrixMode(GL_MODELVIEW);
      glLoadMatrixf(tempMod);
  }
  </code></pre>
  
  <p>Instead I get nothing, just a large empty scene, and I'm unsure how to proceed. My paintGL is essentially:</p>
  
  <pre><code>void GLWidget::paintGL()
  {    
      glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
      glLoadIdentity();
  
      Camera.Render();
  
      glTranslatef(0.0, 0.0, 0.0);
  
      glBegin(GL_QUADS);
          glColor3f(1.0f, 1.0f, 1.0f);
          glVertex3f(50.0f, 0.0f, 50.0f);
          glVertex3f(50.0f, 0.0f, -50.0f);
          glVertex3f(-50.0f, 0.0f, -50.0f);
          glVertex3f(-50.0f, 0.0f, 50.0f);
      glEnd();
  
      drawAxis();
  </code></pre>
  
  <p>}</p>
  
  <p>Not calling the draw-axis function still gives me my plane, with it, I get a large blank scene. Am I missing something in how I'm implementing the drawAxis? Should I setup another camera for the function or something like that?</p>