Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | 1x 1x 1x 1x 1x 1x 1x | import GLProvider from './GLProvider'; import ProxyGLProvider from './ProxyGLProvider'; import BasicGLProvider from './BasicGLProvider'; import checkGLError, {ignoreGLErrors} from 'parsegraph-checkglerror'; import {compileShader} from 'parsegraph-shader'; function compileProgram( window:GLProvider, shaderName:string, vertexShader:string, fragShader:string, ) { const gl = window.gl(); const shaders = window.shaders(); if (gl.isContextLost()) { return; } if (shaders[shaderName]) { return shaders[shaderName]; } const program = gl.createProgram(); checkGLError( gl, 'compileProgram.createProgram(shaderName=\'', shaderName, ')', ); const compiledVertexShader = compileShader( gl, vertexShader, gl.VERTEX_SHADER, shaderName, ); checkGLError( gl, 'compileProgram.compile vertex shader(shaderName=\'', shaderName, ')', ); gl.attachShader(program, compiledVertexShader); checkGLError( gl, 'compileProgram.attach vertex shader(shaderName=\'', shaderName, ')', ); const compiledFragmentShader = compileShader( gl, fragShader, gl.FRAGMENT_SHADER, shaderName, ); checkGLError( gl, 'compileProgram.compile fragment shader(shaderName=\'', shaderName, ')', ); gl.attachShader(program, compiledFragmentShader); checkGLError( gl, 'compileProgram.attach fragment shader(shaderName=\'', shaderName, ')', ); gl.linkProgram(program); if (!ignoreGLErrors()) { const st = gl.getProgramParameter(program, gl.LINK_STATUS); if (!st) { throw new Error( '\'' + shaderName + '\' shader program failed to link:\n' + gl.getProgramInfoLog(program), ); } const err = gl.getError(); if (err != gl.NO_ERROR && err != gl.CONTEXT_LOST_WEBGL) { throw new Error( '\'' + shaderName + '\' shader program failed to link: ' + err, ); } } shaders[shaderName] = program; // console.log("Created shader for " + shaderName + ": " + program); return program; } export { compileProgram, GLProvider, BasicGLProvider, ProxyGLProvider } |