1251091-1.html 1.3 KB

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