1251091-1.html (1344B)
1 <!doctype html> 2 <html class="reftest-wait"> 3 <head> 4 <script type="text/javascript"> 5 var gl; 6 7 function start() { 8 var canvas = document.getElementById("glcanvas"); 9 gl = canvas.getContext("webgl") || canvas.getContext("experimental-webgl"); 10 11 if (gl) { 12 initTextures(); 13 } else { 14 finish(); 15 } 16 } 17 18 function initTextures() { 19 var cubeTexture = gl.createTexture(); 20 var cubeImage = document.getElementById("i"); 21 cubeImage.onload = function() { handleTextureLoaded(cubeImage, cubeTexture); } 22 cubeImage.onerror = function() { finish(); } 23 cubeImage.src = "1251091-1.png"; 24 } 25 26 function handleTextureLoaded(image, texture) { 27 gl.bindTexture(gl.TEXTURE_2D, texture); 28 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image); 29 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); 30 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_NEAREST); 31 gl.generateMipmap(gl.TEXTURE_2D); 32 gl.bindTexture(gl.TEXTURE_2D, null); 33 setTimeout(showit,0); 34 } 35 36 function showit() { 37 document.getElementById("i").style.display = ""; 38 finish(); 39 } 40 41 function finish() { 42 document.documentElement.removeAttribute("class"); 43 } 44 </script> 45 </head> 46 47 <body onload="start()"> 48 <canvas id="glcanvas" width="640" height="480"></canvas> 49 <img id="i" style="display: none;"> 50 </body> 51 </html>