将顶点属性(位置、纹理、颜色、法线)索引与着色器中的变量名进行绑定,如此一来就不需要在着色器中定义该变量(会提示重定义),直接使用即可。再配合glVertexAttribPointer就可以给该属性变量赋值了。
void glBindAttribLocation( GLuint program,
GLuint index,
const GLchar *name);
program
Specifies the handle of the program object in which the association is to be made.
指定着色器程序标识符
index
Specifies the index of the generic vertex attribute to be bound.
指定顶点属性索引
name
Specifies a null terminated string containing the name of the vertex shader attribute variable to which index is to be bound.
指定着色器程序中的变量名字符串