# 启动深度测试

``````glEnable(GL_DEPTH_TEST);
``````

# 模型矩阵

``````glm::mat4 mode = glm::mat4(1.0f);
mode = glm::rotate(mode, (float)glfwGetTime() * glm::radians(50.0f), glm::vec3(0.5f, 1.0f, 0.0f));
``````

# 观察矩阵

``````glm::mat4 view = glm::mat4(1.0f);
view = glm::translate(view, glm::vec3(0.0f, 0.0f, -3.0f));
``````

# 投影矩阵

`````` glm::mat4 projection = glm::mat4(1.0f);
projection = glm::perspective(glm::radians(45.0f), (float)viewwidth / (float)viewheight, 0.1f, 100.0f);
``````

``````glm::ortho(左, 右, 底, 顶, 近, 远);
``````

``````glm::mat4 proj = glm::perspective
``````

# 管线

#### uniform

``````uniform mat4 mode = {{1,0,0,0},{0,1,0,0},{0,0,1,0},{0,0,0,1}};
uniform mat4 view = {{1,0,0,0},{0,1,0,0},{0,0,1,0},{0,0,0,1}};
uniform mat4 projection = {{1,0,0,0},{0,1,0,0},{0,0,1,0},{0,0,0,1}};
``````

#### 图形变换

gl_Position = projection * view * mode * vec4(aPos, 1.0);//顺序一定不能错

# 重点

``````for (unsigned int i = 0; i < 10; i++){
float angle = 20.0f * i;
mode = glm::mat4(1.0f);//**1**
mode = glm::translate(mode, cubePositions[i]);//**2**
mode = glm::rotate(mode, (float)glfwGetTime() * glm::radians(50.0f), glm::vec3(0.5f, 1.0f, 0.0f));//**3**
mode = glm::rotate(mode, glm::radians(angle), glm::vec3(1.0f, 0.3f, 0.5f));//**4**
}
``````

mode = 4(自身旋转) * 3(按时间轴旋转) * 2(移动一定距离) * 1(单位矩阵)

``````gl_Position =   projection * view * mode * vec4(aPos, 1.0);
``````