mirror of
https://github.com/JoeyDeVries/LearnOpenGL.git
synced 2026-01-30 20:13:22 +08:00
Rename all occurences of 'Lamp' in Lighting chapter to 'LightCube' (VAO and Shaders).
This commit is contained in:
@@ -78,7 +78,7 @@ int main()
|
||||
// build and compile our shader zprogram
|
||||
// ------------------------------------
|
||||
Shader lightingShader("3.1.materials.vs", "3.1.materials.fs");
|
||||
Shader lampShader("3.1.lamp.vs", "3.1.lamp.fs");
|
||||
Shader lightCubeShader("3.1.light_cube.vs", "3.1.light_cube.fs");
|
||||
|
||||
// set up vertex data (and buffer(s)) and configure vertex attributes
|
||||
// ------------------------------------------------------------------
|
||||
@@ -144,9 +144,9 @@ int main()
|
||||
|
||||
|
||||
// second, configure the light's VAO (VBO stays the same; the vertices are the same for the light object which is also a 3D cube)
|
||||
unsigned int lightVAO;
|
||||
glGenVertexArrays(1, &lightVAO);
|
||||
glBindVertexArray(lightVAO);
|
||||
unsigned int lightCubeVAO;
|
||||
glGenVertexArrays(1, &lightCubeVAO);
|
||||
glBindVertexArray(lightCubeVAO);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, VBO);
|
||||
// note that we update the lamp's position attribute's stride to reflect the updated buffer data
|
||||
@@ -211,15 +211,15 @@ int main()
|
||||
|
||||
|
||||
// also draw the lamp object
|
||||
lampShader.use();
|
||||
lampShader.setMat4("projection", projection);
|
||||
lampShader.setMat4("view", view);
|
||||
lightCubeShader.use();
|
||||
lightCubeShader.setMat4("projection", projection);
|
||||
lightCubeShader.setMat4("view", view);
|
||||
model = glm::mat4(1.0f);
|
||||
model = glm::translate(model, lightPos);
|
||||
model = glm::scale(model, glm::vec3(0.2f)); // a smaller cube
|
||||
lampShader.setMat4("model", model);
|
||||
lightCubeShader.setMat4("model", model);
|
||||
|
||||
glBindVertexArray(lightVAO);
|
||||
glBindVertexArray(lightCubeVAO);
|
||||
glDrawArrays(GL_TRIANGLES, 0, 36);
|
||||
|
||||
|
||||
@@ -232,7 +232,7 @@ int main()
|
||||
// optional: de-allocate all resources once they've outlived their purpose:
|
||||
// ------------------------------------------------------------------------
|
||||
glDeleteVertexArrays(1, &cubeVAO);
|
||||
glDeleteVertexArrays(1, &lightVAO);
|
||||
glDeleteVertexArrays(1, &lightCubeVAO);
|
||||
glDeleteBuffers(1, &VBO);
|
||||
|
||||
// glfw: terminate, clearing all previously allocated GLFW resources.
|
||||
|
||||
Reference in New Issue
Block a user