WebGLActiveInfo代表的 glContext的“getActiveAttrib”和“getActiveuniform”两个方法返回的信息。 主要目的是获取着色器程序的 atttribute 和 uniform 定义的参数
const numAttribs = gl.getProgramParameter( shaderProgram, gl.ACTIVE_ATTRIBUTES );
const numUniform = gl.getProgramParameter( shaderProgram, gl.ACTIVE_UNIFORMS );
WebGLActiveInfo有三个属性 分别为 name 、type和 size 。
const numAttribs = gl.getProgramParameter( shaderProgram, gl.ACTIVE_ATTRIBUTES );
console.log("numAttribs: ", numAttribs);
const numUniform = gl.getProgramParameter( shaderProgram, gl.ACTIVE_UNIFORMS );
console.log("numUniform: ", numUniform);
for (let index = 0; index < numAttribs; index++) {
const element = gl.getActiveAttrib(shaderProgram, index);
console.log("element: ", element);
}
for (let index = 0; index < numUniform; index++) {
const element = gl.getActiveUniform(shaderProgram, index);
console.log("element: ", element);
}