const canvas = document.getElementById('webgl'); // if webgl context isnot exist, init it const webgl = canvas.getContext('webgl');
// Set clear color to black, fully opaque webgl.clearColor(0.0, 0.0, 0.0, 1.0); // Clear the color buffer with specified clear color webgl.clear(webgl.COLOR_BUFFER_BIT);
//片元着色器(Programmable Fragment Processor)源码 let fragShaderSource = '' + 'void main(){' + //定义片元颜色 ' gl_FragColor = vec4(1.0,0.0,0.0,1.0);' + '}';
//初始化着色器 let program = this.initShader(this.gl, vertexShaderSource, fragShaderSource); //获取顶点着色器的位置变量apos var aposLocation = this.gl.getAttribLocation(program, 'apos');