| <script> |
| |
| if (window.testRunner) |
| window.testRunner.dumpAsText(); |
| |
| function createShader(str, type) { |
| var shader = gl.createShader(type); |
| gl.shaderSource(shader, str); |
| gl.compileShader(shader); |
| return shader; |
| } |
| |
| function createProgram(vstr, fstr) { |
| var program = gl.createProgram(); |
| var vshader = createShader(vstr, gl.VERTEX_SHADER); |
| var fshader = createShader(fstr, gl.FRAGMENT_SHADER); |
| gl.attachShader(program, vshader); |
| gl.attachShader(program, fshader); |
| gl.linkProgram(program); |
| return program; |
| } |
| |
| var canvas = document.createElement("canvas"); |
| var gl = canvas.getContext("webgl"); |
| |
| var vs = 'attribute vec2 pos; void main() { gl_Position = vec4(pos, 0, 1); }'; |
| var fs = 'precision mediump float; void main() { gl_FragColor = vec4(0,0.8,0,1); }'; |
| var program = createProgram(vs, fs); |
| gl.useProgram(program); |
| gl.drawArrays(0, 0, 0x4000000); |
| </script> |