webgl 坐标系转换
绘制多个点 1、通过变量来传递顶点坐标,获取顶点坐标变量的位置 var a_Position = gl.getAttribLocation(program, ‘a_Position’) 2、传入变量坐标 gl.vertexAttrib3f(a_Position, x, y, z) 3、canvas坐标系转为webgl坐标系,webgl的坐标是x[-1, 1],y[-1, 1] var VERTEX_SOURCE = `attribute vec4 a_Position;\n void main() {\n gl_Position = a_Position;\n gl_PointSize = 10.0;\n }\n` ; var FRAGMENT_SOURCE = `void main() {\n gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);\n }\n` ; function main ( ) { var canvas = document . querySeletor ( '#webgl' ) ; var gl = canvas . getContext ( 'webgl' ) || canvas . getContext ( 'experimental-webgl' ) ; var vertexShader = gl .