function main(){ var canvas = document.getElementById("webgl"); var gl = getWebGLContext(canvas) if (!gl){ console.log("Fail to get WebGL context"); return; }else{ ; } var VSHADER_SOURCE = function(){ /* void main(){ gl_Position = vec4(0.0,0.0,0.0,1.0); gl_PointSize = 10.0; } */ }.toString().match(/\/\*([^]*)\*\//)[1]; var FSHADER_SOURCE = function(){ /* void main(){ gl_FragColor = vec4(1.0,0.0,0.0,1.0); } */ }.toString().match(/\/\*([^]*)\*\//)[1]; if (!initShaders(gl,VSHADER_SOURCE,FSHADER_SOURCE)){ console.log(‘Fail to init shaders‘); return; } gl.clearColor(0.0,0.0,0.0,0.8); gl.clear(gl.COLOR_BUFFER_BIT); gl.drawArrays(gl.POINTS, 0, 1); }
时间: 2024-11-03 03:30:45