title: How to Crop and Scale a Texture in OpenGL
body: <p>I have an input texture that is 852x640 and an output texture that is 612x612. I am passing the input through a shader and want the output to be scaled and cropped properly. I'm having trouble getting the <code>squareCoordinates</code>, <code>textureCoordinates</code> and <code>viewPorts</code> to work properly together.</p>
  
  <p>I do not want to just crop, I want to scale it as well to get the most amount of the image as possible. If I were using Photoshop I'd do this in two steps (in OpenGL I'm trying to do this in one step):</p>
  
  <ol>
  <li>Scale the image to 612x814</li>
  <li>Crop off the excess 101px at each side</li>
  </ol>
  
  <p>I'm using standard square vertices and texture vertices:</p>
  
  <pre><code>static const GLfloat squareVertices[] = {
      -1.0f, -1.0f,
      1.0f, -1.0f,
      -1.0f,  1.0f,
      1.0f,  1.0f,
  };
  
  static const GLfloat squareTextureVertices[] = {
      0.0f, 0.0f,
      1.0f, 0.0f,
      0.0f,  1.0f,
      1.0f,  1.0f
  }
  </code></pre>
  
  <p>I don't exactly know what the viewPort should be.</p>