title: Function to draw text on screen using C++/OpenGL/Glut faster than glutBitmapCharacter
body: <p>I need something muuuch faster than glutBitmapCharacter(font, text[i]). It's decreasing performacne few times ! I need to display fps, xyz position etc. so not in 3D just displaying HUD.</p>
  
  <p>Currently I'm using :</p>
  
  <pre><code>glRasterPos2f(x,y);
  
  for (int i=0; i&lt;text.size(); i++)
  {
     glutBitmapCharacter(font, text[i]);
  }
  </code></pre>
  
  <p>I'm using this function :</p>
  
  <pre><code>void glutPrint(float x, float y, LPVOID font, string text) 
  { 
      glRasterPos2f(x,y); 
  
      for (int i=0; i&lt;text.size(); i++)
      {
          glutBitmapCharacter(font, text[i]);
      }
  }
  </code></pre>
  
  <p>Every frame in DisplayFunction in drawing HUD section (calling DrawHUD()) :</p>
  
  <pre><code>void DrawHUD (void)
  {
      glMatrixMode(GL_PROJECTION);
      glPushMatrix();
      glLoadIdentity();
      glOrtho(0.0, windowWidth, windowHeight, 0.0, -1.0, 10.0);
      glMatrixMode(GL_MODELVIEW);
      glLoadIdentity();
  
      glClear(GL_DEPTH_BUFFER_BIT);
      glColor3f(0.2f,0.2f,0.2f);
  
      glutPrint(2,10,glutFonts[4],its(sfps)+" fps; "+its(todrawquads)+" quads drawing; ");
  
      glMatrixMode(GL_PROJECTION);
      glPopMatrix();
      glMatrixMode(GL_MODELVIEW);
  
  }
  </code></pre>
  
  <p>Also using int to string function :</p>
  
  <pre><code>string its(int i)
  {
  stringstream out;
  out &lt;&lt; i;
  return out.str();
  }
  </code></pre>
  
  <h1>some fact about performance (measured in FPS)</h1>
  
  <p>Without calling DrawHUD function <strong>~ 3500</strong></p>
  
  <p>With calling DrawHUD function <strong>~ 3500</strong> (maybe few less fps)</p>
  
  <p>With DrawHUD + 1 x GlutPrint <strong>~ 3300</strong></p>
  
  <p>With DrawHUD + 2 x GlutPrint <strong>~ 2400</strong></p>
  
  <p>With DrawHUD + 3 x GlutPrint <strong>~ 1700</strong></p>
  
  <p>(eg. when I mean <em>3 x GlutPrint</em> I meant in DrawHUD :</p>
  
  <pre><code>{
  [...]
  
  glutPrint(...);
  glutPrint(...);
  glutPrint(...);
  
  [...]
  }
  </code></pre>
  
  <p>)</p>
  
  <p>That's not nice ... I know measuring using frame rate isn't good.</p>
  
  <h1>also</h1>
  
  <p>when I commented :</p>
  
  <p>glutBitmapCharacter(font, text[i]);</p>
  
  <p>in loop in glutPrint there was ~3500 fps ... so I'm <strong>SURE</strong> that glutBitmapCharacter is problem. So what use instead it :) ?</p>
  
  <p>Then what to do ?</p>