Html程序  |  26行  |  535 B

<!DOCTYPE HTML>
<html>
<script>
var gl;
function runTest() {
  if (window.testRunner)
    testRunner.waitUntilDone();

  gl = document.getElementById('canvas').getContext("webgl");
  if (!gl) {
    alert("No WebGL context found");
    return;
  }

  gl.enable(gl.SCISSOR_TEST);
  gl.clearColor(1, 0, 0, 1);
  gl.clear(gl.COLOR_BUFFER_BIT);
}

</script>
<body onload='runTest()'>
  Right click red square and save image. A red square image should be saved. <br>
  <canvas id='canvas'  width="100" height="100"></canvas>
</body>
</html>