let a_Position = gl.getAttribLocation(gl.program,"a_Position"); //返回attribute变量位置,否则-1(具有webgl_或者gl_前缀或变量不存在) let u_FragColor = gl.getUniformLocation(gl.program,"u_FragColor"); //返回uniform变量位置,否则null
gl.vertexAttrib1f(a_Position,v1); gl.vertexAttrib2f(a_Position,v1,v2); gl.vertexAttrib3f(a_Position,v1,v2,v3); gl.vertexAttrib4f(a_Position,v1,v2,v3,v4); //或者用以v结尾函数版本 let position = new Float32Atrray([1.0, 2.0, 3.0, 1.0]); gl.vertexAttrib4fv(a_Position,position)
gl.uniform1f(u_FragColor,v1); gl.uniform2f(u_FragColor,v1,v2); gl.uniform3f(u_FragColor,v1,v2,v3); gl.uniform4f(u_FragColor,v1,v2,v3,v4); //或者用以v结尾函数版本 let color = new Float32Atrray([1.0, 2.0, 3.0, 1.0]); gl.uniform4fv(u_FragColor,color)