| 903 | |
| 904 | |
| 905 | function compileSource(type, source) { |
| 906 | var shader = gl.createShader(type); |
| 907 | gl.shaderSource(shader, source); |
| 908 | gl.compileShader(shader); |
| 909 | if(!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) { |
| 910 | throw 'compile error: ' + gl.getShaderInfoLog(shader); |
| 911 | } |
| 912 | return shader; |
| 913 | } |
| 914 | this.program = gl.createProgram(); |
| 915 | gl.attachShader(this.program, compileSource(gl.VERTEX_SHADER, vertexSource)); |
| 916 | gl.attachShader(this.program, compileSource(gl.FRAGMENT_SHADER, fragmentSource)); |