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:
@@ -80,7 +80,7 @@ int main()
|
||||
// build and compile our shader zprogram
|
||||
// ------------------------------------
|
||||
Shader lightingShader("4.4.lighting_maps.vs", "4.4.lighting_maps.fs");
|
||||
Shader lampShader("4.4.lamp.vs", "4.4.lamp.fs");
|
||||
Shader lightCubeShader("4.4.light_cube.vs", "4.4.light_cube.fs");
|
||||
|
||||
// set up vertex data (and buffer(s)) and configure vertex attributes
|
||||
// ------------------------------------------------------------------
|
||||
@@ -145,9 +145,9 @@ int main()
|
||||
glEnableVertexAttribArray(2);
|
||||
|
||||
// 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
|
||||
@@ -226,15 +226,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);
|
||||
|
||||
|
||||
@@ -247,7 +247,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