首页 > 代码库 > getAttribLocation的返回值
getAttribLocation的返回值
var coord = gl.getAttribLocation(shaderProgram, "coordinates"); // 0
var coord2 = gl.getAttribLocation(shaderProgram, "coordinates2"); // 1
var coord = gl.getAttribLocation(shaderProgram, "coordinates"); // 1
var coord2 = gl.getAttribLocation(shaderProgram, "coordinates2"); // 0
说明:按照声明顺序,而不是main中使用顺序记录的,0,1,2,3,4.。。。
----------------------------------------------------------------------------------------
var coord = gl.getAttribLocation(shaderProgram, "coordinates"); // 0
var coord2 = gl.getAttribLocation(shaderProgram, "coordinates2"); // -1
var coord = gl.getAttribLocation(shaderProgram, "coordinates"); // 0
var coord2 = gl.getAttribLocation(shaderProgram, "coordinates2"); // -1
说明:虽然声明,但是未在main中使用,则为-1,第一个使用的为0,不再跟声明顺序有关。
getAttribLocation的返回值