title: Draw 2D Text in fixed position on the display in a 3D world - OpenGL
body: <p>I am creating a very simple OpenGL game in C++, with a 3D model moving in a 3D world. I have to put on the screen some 2D text: the camera is constantly following the model and I would like the text to appear in a fixed position with respect to the window.</p>
  
  <p>I tried to use a tutorial from Nehe but, in that case, the gluLookAt is in a fixed position (looking from "high", down to the world) and text is obviously displayed correctly.</p>
  
  <p>Unfortunately, I did not succeded in doing what I want with glRotatef/glTranslatef. </p>
  
  <p>Can anyone help me? How can I display text in a fixed position while camera is moving?
  I already looked for a solution in other threads but in no one I found a suitable solution (in particular, solutions exploiting glut function, which are very common, did not seem to work in my case).</p>
  
  <p>I also premise that I already implemented all the functions to build/kill fonts etc. as explained in the Nehe tutorial I followed.</p>
  
  <p>EDIT:
  I attach the code I have just written. Unfortunately it does not work but I do not understand why (and actually I did not understand how raster position exactly works).</p>
  
  <pre><code>...
  //Here I draw the rest of the scene
  ....
  //now I try to display the text
  glMatrixMode(GL_PROJECTION);
  glPushMatrix();
  glLoadIdentity();
  gluOrtho2D(0.0, width, 0.0, height);
  glMatrixMode(GL_MODELVIEW);
  glPushMatrix();
  glLoadIdentity();
  glRasterPos2i(100, 100);
  glPrint("SAMPLE TEXT");
  glPopMatrix();
  glMatrixMode(GL_PROJECTION);
  glPopMatrix();
  </code></pre>