title: How to fill a hill with a custom texture using OpenGl?
body: <p>I am trying to learn OpenGl be reading various tutorials, so I was looking at <a href="http://www.raywenderlich.com/32954/how-to-create-a-game-like-tiny-wings-with-cocos2d-2-x-part-1" rel="nofollow noreferrer">http://www.raywenderlich.com/32954/how-to-create-a-game-like-tiny-wings-with-cocos2d-2-x-part-1</a></p>
  
  <p>In that tutorial, he basically takes a texture with stripes:</p>
  
  <p><img src="https://i.stack.imgur.com/7KlKQ.jpg" alt="Rectangular texture with stripes"></p>
  
  <p>And wraps it around a hill to look like:</p>
  
  <p><img src="https://i.stack.imgur.com/qFpI3.jpg" alt="Hills with stripes"></p>
  
  <p>Her creates the vertices and texture coordinates, by taking the coordinates of the top of the hill and creating a triangle strip</p>
  
  <pre><code>    _hillVertices[_nHillVertices] = CGPointMake(pt0.x, 0 + minY);
      _hillTexCoords[_nHillVertices++] = CGPointMake(pt0.x/512, 1.0f);
      _hillVertices[_nHillVertices] = CGPointMake(pt1.x, 0 + minY);
      _hillTexCoords[_nHillVertices++] = CGPointMake(pt1.x/512, 1.0f);
  
      _hillVertices[_nHillVertices] = CGPointMake(pt0.x, pt0.y);
      _hillTexCoords[_nHillVertices++] = CGPointMake(pt0.x/512, 0);
      _hillVertices[_nHillVertices] = CGPointMake(pt1.x, pt1.y);
      _hillTexCoords[_nHillVertices++] = CGPointMake(pt1.x/512, 0);
  </code></pre>
  
  <p>My question is, what if I had the same texture with stripes, but wanted to render it on to the hills without distortion ? You will notice from the hill image, that the texture is somewhat wrapped around the hills (so all the stripes are curved), but how would I apply the texture so it is straight lines exactly like the original image ?</p>
  
  <p>I am using OpenGl-es 2.0.</p>
  
  <p>EDIT.</p>
  
  <p>I tried setting the texture-coordinates the same as the vertex coordinates, but it didn't work out exactly as I hoped:</p>
  
  <p><img src="https://i.stack.imgur.com/cBHzj.png" alt="My texture"></p>
  
  <p><img src="https://i.stack.imgur.com/xrTKX.png" alt="enter image description here"></p>
  
  <p>The first image shows the texture. And the second image is the effect when applied to the hills. The stripes are no longer "wavy", but they seem much larger than the original texture, and seem to be oriented the wrong way. How do I correct this ? My modified code is</p>
  
  <pre><code>    _hillTexCoords[tcc++]=CGPointMake(p0.x/512, 0+_minY);
      _hillTexCoords[tcc++]=CGPointMake(p0.x/512, p0.y/512);
  </code></pre>