Guest User

Untitled

a guest
Dec 4th, 2016
1,738
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 2.17 KB | None | 0 0
  1. diff --git a/prog5/prog5.html b/prog5/prog5.html
  2. index 1a75e38..38ca76a 100644
  3. --- a/prog5/prog5.html
  4. +++ b/prog5/prog5.html
  5. @@ -91,7 +91,7 @@ Project 5 -->
  6.                      Z-AXIS<input id="z-light" type="range" min="-5.0" max="5.0" value="0" step="0.1" oninput="refresh()">
  7.                  </font>
  8.              </center>
  9. -        <video id="video" src="Firefox.ogv" autoplay muted>
  10. +        <video id="video" src="Firefox.ogv" autoplay muted style="display: none;">
  11.        Your browser doesn't appear to support the <code>&lt;video&gt;</code> element.
  12.          </video>
  13.  
  14. diff --git a/prog5/prog5.js b/prog5/prog5.js
  15. index 3bbd660..77b6710 100644
  16. --- a/prog5/prog5.js
  17. +++ b/prog5/prog5.js
  18. @@ -21,6 +21,7 @@ var lastClientY;
  19.  
  20.  var videoElement;
  21.  var modelTexture;
  22. +var copyVideo;
  23.  
  24.  //refresh function used to request animation frame after moving slider in HTML
  25.  function refresh(){
  26. @@ -171,7 +172,6 @@ function loadTexture(image, texture){
  27.    gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
  28.    gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  29.    gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  30. -    requestAnimationFrame(draw);                                                        
  31.  }
  32.  
  33.  
  34. @@ -194,8 +194,14 @@ function init(){
  35.      videoElement = document.getElementById("video");
  36.  
  37.      modelTexture    = gl.createTexture();
  38. +    // put 1 pixel in it so we can render before the video starts
  39. +    gl.bindTexture(gl.TEXTURE_2D, modelTexture);
  40. +    gl.texImage2D(
  41. +        gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE,
  42. +        new Uint8Array([255, 255, 255, 255]));
  43.  
  44.      videoElement.addEventListener("canplaythrough", startVideo, true);
  45. +    videoElement.addEventListener("playing", () => { copyVideo = true; }, true);
  46.      videoElement.addEventListener("ended", videoDone, true);
  47.  
  48.     /* videoElement.onload   = function() {
  49. @@ -217,7 +223,9 @@ function init(){
  50.  
  51.  
  52.  function draw(){
  53. +    if (copyVideo) {
  54.        updateTexture();
  55. +    }
  56.      //compose matrices for transformations
  57.      var viewMatrix          = new Matrix4();
  58.      var projectionMatrix    = new Matrix4();
Advertisement
Add Comment
Please, Sign In to add comment