Update 04-07 and 09 chapters

This commit is contained in:
Mouse
2019-12-27 16:44:15 +08:00
parent 9c0958eb78
commit 41f0fcf136
5 changed files with 8 additions and 51 deletions

View File

@@ -265,7 +265,7 @@ glBindVertexArray(vaoId);
vboId = glGenBuffers();
glBindBuffer(GL_ARRAY_BUFFER, vboId);
glBufferData(GL_ARRAY_BUFFER, verticesBuffer, GL_STATIC_DRAW);
memFree(verticesBuffer);
glEnableVertexAttribArray(0);
```
接下来是最重要的部分。我们需要定义数据结构并将其储存在VAO的属性列表中这是用下述代码完成的
@@ -316,13 +316,11 @@ public void render(Window window) {
// 绑定VAO
glBindVertexArray(vaoId);
glEnableVertexAttribArray(0);
// 绘制顶点
glDrawArrays(GL_TRIANGLES, 0, 3);
// 还原状态
glDisableVertexAttribArray(0);
glBindVertexArray(0);
shaderProgram.unbind();