webgl-save-image-as.html 535 B

12345678910111213141516171819202122232425
  1. <!DOCTYPE HTML>
  2. <html>
  3. <script>
  4. var gl;
  5. function runTest() {
  6. if (window.testRunner)
  7. testRunner.waitUntilDone();
  8. gl = document.getElementById('canvas').getContext("webgl");
  9. if (!gl) {
  10. alert("No WebGL context found");
  11. return;
  12. }
  13. gl.enable(gl.SCISSOR_TEST);
  14. gl.clearColor(1, 0, 0, 1);
  15. gl.clear(gl.COLOR_BUFFER_BIT);
  16. }
  17. </script>
  18. <body onload='runTest()'>
  19. Right click red square and save image. A red square image should be saved. <br>
  20. <canvas id='canvas' width="100" height="100"></canvas>
  21. </body>
  22. </html>