title: How to crop HTMLVideoElement in WebGL's texImage2D?
body: <p>I'm playing around with WebGL, and I can successfully render a video element to a WebGL context with <a href="https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/texImage2D" rel="nofollow noreferrer"><code>texImage2D</code></a>. However, I'm now trying to crop this video element before rendering it. For example, I want to take the top half of the video element and draw it in the left half of my GL context; and the bottom half in the right half.</p>
  
  <p><img src="https://i.stack.imgur.com/rmLEa.png" alt="image1"></p>
  
  <p><strong>What is the best practice for this "crop action" in WebGL 1?</strong></p>
  
  <p>I have figured out that I can adjust the <a href="https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/viewport" rel="nofollow noreferrer">viewport</a> to render something in the left/right half, but I can't seem to find how to crop.</p>
  
  <p>It would be nice if <a href="https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/texImage2D" rel="nofollow noreferrer"><code>texImage2D</code></a> supported offset and dimension parameters for video elements, but that's not the case.  </p>
  
  <p>Maybe I can adjust this in the texture parameters or something?</p>