title: OpenGL - Maintain texture width to height ratio
body: <p>I have a 256x256 crate texture and a plane twice as long as it is high.</p>
  
  <p>I'd like to maintain the texture's aspect ratio and control it's scaling factor, rather than stretch it to all corners as shown below.</p>
  
  <p><a href="https://i.stack.imgur.com/VaRSu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VaRSu.png" alt="enter image description here"></a></p>
  
  <p>This is my object data:</p>
  
  <pre><code>// Vertex Positions
  Vector3 vertices = new Vector3[] {
              new Vector3( 1,  0,  1),
              new Vector3( 3,  0,  1),
              new Vector3( 3,  1,  1),
              new Vector3( 1,  1,  1)};
  
  // Index Order
  int[] indices = new int[] {0, 1, 2,   0, 2, 3};
  
  // Texture Co-ordinates
  Vector2 texcoords = new Vector2[] {
              new Vector2 (0.0f, 0.0f),
              new Vector2 (1.0f, 0.0f),
              new Vector2 (1.0f, 1.0f),
              new Vector2 (0.0f, 1.0f)};
  
  // Normals
  Vector3 normals = new Vector3[] {
              new Vector3 (0.0f, 0.0f, 1.0f),
              new Vector3 (0.0f, 0.0f, 1.0f),
              new Vector3 (0.0f, 0.0f, 1.0f),
              new Vector3 (0.0f, 0.0f, 1.0f)};
  </code></pre>
  
  <p>I have enabled texture repeating with the following:</p>
  
  <pre><code>GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, Convert.ToInt32(TextureWrapMode.Repeat));
  GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, Convert.ToInt32(TextureWrapMode.Repeat));
  </code></pre>
  
  <p>By matching the texture co-ordinates to the plane's height and width, the texture does repeat as intended.</p>
  
  <pre><code>// Texture Co-ordinates
  Vector2 texcoords = new Vector2[] {
              new Vector2 (0.0f, 0.0f),
              new Vector2 (2.0f, 0.0f),
              new Vector2 (2.0f, 1.0f),
              new Vector2 (0.0f, 1.0f)};
  </code></pre>
  
  <p>However, I'd like for all 256x256 textures to display consistent in size, regardless of the plane size.</p>