title: OpenGL: Fit scene to screen
body: <p>I have a 3D scene with a perspective projection.</p>
  
  <p>I want to fit the scene to the screen based on a bounding box (<code>min</code> and <code>max</code>).</p>
  
  <p>I have centered my scene like this:</p>
  
  <pre><code>glm::vec3 center = (min + max) / 2.0f;
  rootNode-&gt;translate(-center.x, -center.y, -center.z);
  </code></pre>
  
  <p>Now I need a scale factor to scale my rootNode to fit the screen.
  How do I do this?</p>
  
  <p>(this: <a href="https://www.opengl.org/archives/resources/faq/technical/viewing.htm" rel="nofollow">8.070 How can I automatically calculate a view that displays my entire model? (I know the bounding sphere and up vector.)</a> does not help because its based on a orthogonal projection)</p>