title: Center bitmap text to a rectangle with OpenGL
body: <p>I need to center a piece of text to a rectangle.</p>
  
  <p>I found this <a href="http://lazyfoo.net/tutorials/OpenGL/24_text_alignment/index.php" rel="nofollow">example</a>, but I'm struggling to understand what it does.</p>
  
  <p>It is not too hard to achieve this, I just need to know how do I find the width and the height of the text after being drawn, but I cannot find this anywhere.</p>
  
  <p>To draw the text, I do it char by char:</p>
  
  <pre><code>static void drawText(std::string str, float x, float y, float z) {
      glRasterPos3f(x, y, z);
      for (unsigned int i = 0; i &lt; str.size(); i++) {
          glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, str[i]);
      }
  }
  </code></pre>
  
  <p>Not sure if this is the best way, but it is my first program using OpenGL.</p>