bob*_*obo 60
GLSL参考手册的5.6节说明您可以mat4使用operator[][]样式语法以下列方式访问数组元素:
mat4 m;
m[1] = vec4(2.0); // sets the second column to all 2.0
m[0][0] = 1.0; // sets the upper left element to 1.0
m[2][3] = 2.0; // sets the 4th element of the third column to 2.0
Run Code Online (Sandbox Code Playgroud)
请记住,OpenGL默认为列主要矩阵,这意味着访问具有格式mat[col][row].在该示例中,m[2][3]将第3列(索引2)的第4行(索引3)设置为2.0.在该示例中m[1]=vec4(2.0),它一次设置整个列(因为m[1]引用列#2,当仅使用一个索引时,它意味着COLUMN.m[1]引用第二列矢量).