Update GLM to latest version (0.9.9.3). This includes GLM's change of matrices no longer default initializing to the identity matrix. This commit thus also includes the update of all of LearnOpenGL's code to reflect this: all matrices are now constructor-initialized to the identity matrix where relevant.

This commit is contained in:
Joey de Vries
2018-12-30 14:27:14 +01:00
parent 239c456ae9
commit f4b6763356
474 changed files with 38219 additions and 38025 deletions

View File

@@ -167,7 +167,7 @@ int main()
glBindTexture(GL_TEXTURE_2D, texture2);
// create transformations
glm::mat4 transform;
glm::mat4 transform = glm::mat4(1.0f); // make sure to initialize matrix to identity matrix first
transform = glm::translate(transform, glm::vec3(0.5f, -0.5f, 0.0f));
transform = glm::rotate(transform, (float)glfwGetTime(), glm::vec3(0.0f, 0.0f, 1.0f));

View File

@@ -167,7 +167,7 @@ int main()
glBindTexture(GL_TEXTURE_2D, texture2);
glm::mat4 transform;
glm::mat4 transform = glm::mat4(1.0f); // make sure to initialize matrix to identity matrix first
// first container
// ---------------
transform = glm::translate(transform, glm::vec3(0.5f, -0.5f, 0.0f));
@@ -182,7 +182,7 @@ int main()
// second transformation
// ---------------------
transform = glm::mat4(); // reset it to an identity matrix
transform = glm::mat4(1.0f); // reset it to identity matrix
transform = glm::translate(transform, glm::vec3(-0.5f, 0.5f, 0.0f));
float scaleAmount = sin(glfwGetTime());
transform = glm::scale(transform, glm::vec3(scaleAmount, scaleAmount, scaleAmount));

View File

@@ -170,9 +170,9 @@ int main()
ourShader.use();
// create transformations
glm::mat4 model;
glm::mat4 view;
glm::mat4 projection;
glm::mat4 model = glm::mat4(1.0f); // make sure to initialize matrix to identity matrix first
glm::mat4 view = glm::mat4(1.0f);
glm::mat4 projection = glm::mat4(1.0f);
model = glm::rotate(model, glm::radians(-55.0f), glm::vec3(1.0f, 0.0f, 0.0f));
view = glm::translate(view, glm::vec3(0.0f, 0.0f, -3.0f));
projection = glm::perspective(glm::radians(45.0f), (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 100.0f);

View File

@@ -202,9 +202,9 @@ int main()
ourShader.use();
// create transformations
glm::mat4 model;
glm::mat4 view;
glm::mat4 projection;
glm::mat4 model = glm::mat4(1.0f); // make sure to initialize matrix to identity matrix first
glm::mat4 view = glm::mat4(1.0f);
glm::mat4 projection = glm::mat4(1.0f);
model = glm::rotate(model, (float)glfwGetTime(), glm::vec3(0.5f, 1.0f, 0.0f));
view = glm::translate(view, glm::vec3(0.0f, 0.0f, -3.0f));
projection = glm::perspective(glm::radians(45.0f), (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 100.0f);

View File

@@ -215,8 +215,8 @@ int main()
ourShader.use();
// create transformations
glm::mat4 view;
glm::mat4 projection;
glm::mat4 view = glm::mat4(1.0f); // make sure to initialize matrix to identity matrix first
glm::mat4 projection = glm::mat4(1.0f);
projection = glm::perspective(glm::radians(45.0f), (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 100.0f);
view = glm::translate(view, glm::vec3(0.0f, 0.0f, -3.0f));
// pass transformation matrices to the shader
@@ -228,7 +228,7 @@ int main()
for (unsigned int i = 0; i < 10; i++)
{
// calculate the model matrix for each object and pass it to shader before drawing
glm::mat4 model;
glm::mat4 model = glm::mat4(1.0f);
model = glm::translate(model, cubePositions[i]);
float angle = 20.0f * i;
model = glm::rotate(model, glm::radians(angle), glm::vec3(1.0f, 0.3f, 0.5f));

View File

@@ -220,7 +220,7 @@ int main()
ourShader.use();
// camera/view transformation
glm::mat4 view;
glm::mat4 view = glm::mat4(1.0f); // make sure to initialize matrix to identity matrix first
float radius = 10.0f;
float camX = sin(glfwGetTime()) * radius;
float camZ = cos(glfwGetTime()) * radius;
@@ -232,7 +232,7 @@ int main()
for (unsigned int i = 0; i < 10; i++)
{
// calculate the model matrix for each object and pass it to shader before drawing
glm::mat4 model;
glm::mat4 model = glm::mat4(1.0f);
model = glm::translate(model, cubePositions[i]);
float angle = 20.0f * i;
model = glm::rotate(model, glm::radians(angle), glm::vec3(1.0f, 0.3f, 0.5f));

View File

@@ -243,7 +243,7 @@ int main()
for (unsigned int i = 0; i < 10; i++)
{
// calculate the model matrix for each object and pass it to shader before drawing
glm::mat4 model;
glm::mat4 model = glm::mat4(1.0f); // make sure to initialize matrix to identity matrix first
model = glm::translate(model, cubePositions[i]);
float angle = 20.0f * i;
model = glm::rotate(model, glm::radians(angle), glm::vec3(1.0f, 0.3f, 0.5f));

View File

@@ -256,7 +256,7 @@ int main()
for (unsigned int i = 0; i < 10; i++)
{
// calculate the model matrix for each object and pass it to shader before drawing
glm::mat4 model;
glm::mat4 model = glm::mat4(1.0f); // make sure to initialize matrix to identity matrix first
model = glm::translate(model, cubePositions[i]);
float angle = 20.0f * i;
model = glm::rotate(model, glm::radians(angle), glm::vec3(1.0f, 0.3f, 0.5f));

View File

@@ -251,7 +251,7 @@ int main()
for (unsigned int i = 0; i < 10; i++)
{
// calculate the model matrix for each object and pass it to shader before drawing
glm::mat4 model;
glm::mat4 model = glm::mat4(1.0f); // make sure to initialize matrix to identity matrix first
model = glm::translate(model, cubePositions[i]);
float angle = 20.0f * i;
model = glm::rotate(model, glm::radians(angle), glm::vec3(1.0f, 0.3f, 0.5f));

View File

@@ -182,7 +182,7 @@ int main()
lightingShader.setMat4("view", view);
// world transformation
glm::mat4 model;
glm::mat4 model = glm::mat4(1.0f);
lightingShader.setMat4("model", model);
// render the cube
@@ -194,7 +194,7 @@ int main()
lampShader.use();
lampShader.setMat4("projection", projection);
lampShader.setMat4("view", view);
model = glm::mat4();
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);

View File

@@ -186,7 +186,7 @@ int main()
lightingShader.setMat4("view", view);
// world transformation
glm::mat4 model;
glm::mat4 model = glm::mat4(1.0f);
lightingShader.setMat4("model", model);
// render the cube
@@ -198,7 +198,7 @@ int main()
lampShader.use();
lampShader.setMat4("projection", projection);
lampShader.setMat4("view", view);
model = glm::mat4();
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);

View File

@@ -187,7 +187,7 @@ int main()
lightingShader.setMat4("view", view);
// world transformation
glm::mat4 model;
glm::mat4 model = glm::mat4(1.0f);
lightingShader.setMat4("model", model);
// render the cube
@@ -199,7 +199,7 @@ int main()
lampShader.use();
lampShader.setMat4("projection", projection);
lampShader.setMat4("view", view);
model = glm::mat4();
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);

View File

@@ -202,7 +202,7 @@ int main()
lightingShader.setMat4("view", view);
// world transformation
glm::mat4 model;
glm::mat4 model = glm::mat4(1.0f);
lightingShader.setMat4("model", model);
// render the cube
@@ -214,7 +214,7 @@ int main()
lampShader.use();
lampShader.setMat4("projection", projection);
lampShader.setMat4("view", view);
model = glm::mat4();
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);

View File

@@ -196,7 +196,7 @@ int main()
lightingShader.setMat4("view", view);
// world transformation
glm::mat4 model;
glm::mat4 model = glm::mat4(1.0f);
lightingShader.setMat4("model", model);
// render the cube
@@ -208,7 +208,7 @@ int main()
lampShader.use();
lampShader.setMat4("projection", projection);
lampShader.setMat4("view", view);
model = glm::mat4();
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);

View File

@@ -204,7 +204,7 @@ int main()
lightingShader.setMat4("view", view);
// world transformation
glm::mat4 model;
glm::mat4 model = glm::mat4(1.0f);
lightingShader.setMat4("model", model);
// bind diffuse map
@@ -220,7 +220,7 @@ int main()
lampShader.use();
lampShader.setMat4("projection", projection);
lampShader.setMat4("view", view);
model = glm::mat4();
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);

View File

@@ -205,7 +205,7 @@ int main()
lightingShader.setMat4("view", view);
// world transformation
glm::mat4 model;
glm::mat4 model = glm::mat4(1.0f);
lightingShader.setMat4("model", model);
// bind diffuse map
@@ -224,7 +224,7 @@ int main()
lampShader.use();
lampShader.setMat4("projection", projection);
lampShader.setMat4("view", view);
model = glm::mat4();
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);

View File

@@ -207,7 +207,7 @@ int main()
lightingShader.setMat4("view", view);
// world transformation
glm::mat4 model;
glm::mat4 model = glm::mat4(1.0f);
lightingShader.setMat4("model", model);
// bind diffuse map
@@ -229,7 +229,7 @@ int main()
lampShader.use();
lampShader.setMat4("projection", projection);
lampShader.setMat4("view", view);
model = glm::mat4();
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);

View File

@@ -215,7 +215,7 @@ int main()
lightingShader.setMat4("view", view);
// world transformation
glm::mat4 model;
glm::mat4 model = glm::mat4(1.0f);
lightingShader.setMat4("model", model);
// bind diffuse map
@@ -234,7 +234,7 @@ int main()
for (unsigned int i = 0; i < 10; i++)
{
// calculate the model matrix for each object and pass it to shader before drawing
glm::mat4 model;
glm::mat4 model = glm::mat4(1.0f);
model = glm::translate(model, cubePositions[i]);
float angle = 20.0f * i;
model = glm::rotate(model, glm::radians(angle), glm::vec3(1.0f, 0.3f, 0.5f));
@@ -248,7 +248,7 @@ int main()
// lampShader.use();
// lampShader.setMat4("projection", projection);
// lampShader.setMat4("view", view);
// model = glm::mat4();
// 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);

View File

@@ -221,7 +221,7 @@ int main()
lightingShader.setMat4("view", view);
// world transformation
glm::mat4 model;
glm::mat4 model = glm::mat4(1.0f);
lightingShader.setMat4("model", model);
// bind diffuse map
@@ -236,7 +236,7 @@ int main()
for (unsigned int i = 0; i < 10; i++)
{
// calculate the model matrix for each object and pass it to shader before drawing
glm::mat4 model;
glm::mat4 model = glm::mat4(1.0f);
model = glm::translate(model, cubePositions[i]);
float angle = 20.0f * i;
model = glm::rotate(model, glm::radians(angle), glm::vec3(1.0f, 0.3f, 0.5f));
@@ -250,7 +250,7 @@ int main()
lampShader.use();
lampShader.setMat4("projection", projection);
lampShader.setMat4("view", view);
model = glm::mat4();
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);

View File

@@ -222,7 +222,7 @@ int main()
lightingShader.setMat4("view", view);
// world transformation
glm::mat4 model;
glm::mat4 model = glm::mat4(1.0f);
lightingShader.setMat4("model", model);
// bind diffuse map
@@ -237,7 +237,7 @@ int main()
for (unsigned int i = 0; i < 10; i++)
{
// calculate the model matrix for each object and pass it to shader before drawing
glm::mat4 model;
glm::mat4 model = glm::mat4(1.0f);
model = glm::translate(model, cubePositions[i]);
float angle = 20.0f * i;
model = glm::rotate(model, glm::radians(angle), glm::vec3(1.0f, 0.3f, 0.5f));
@@ -251,7 +251,7 @@ int main()
// lampShader.use();
// lampShader.setMat4("projection", projection);
// lampShader.setMat4("view", view);
// model = glm::mat4();
// 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);

View File

@@ -223,7 +223,7 @@ int main()
lightingShader.setMat4("view", view);
// world transformation
glm::mat4 model;
glm::mat4 model = glm::mat4(1.0f);
lightingShader.setMat4("model", model);
// bind diffuse map
@@ -238,7 +238,7 @@ int main()
for (unsigned int i = 0; i < 10; i++)
{
// calculate the model matrix for each object and pass it to shader before drawing
glm::mat4 model;
glm::mat4 model = glm::mat4(1.0f);
model = glm::translate(model, cubePositions[i]);
float angle = 20.0f * i;
model = glm::rotate(model, glm::radians(angle), glm::vec3(1.0f, 0.3f, 0.5f));
@@ -251,7 +251,7 @@ int main()
// lampShader.use();
// lampShader.setMat4("projection", projection);
// lampShader.setMat4("view", view);
// model = glm::mat4();
// 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);

View File

@@ -272,7 +272,7 @@ int main()
lightingShader.setMat4("view", view);
// world transformation
glm::mat4 model;
glm::mat4 model = glm::mat4(1.0f);
lightingShader.setMat4("model", model);
// bind diffuse map
@@ -287,7 +287,7 @@ int main()
for (unsigned int i = 0; i < 10; i++)
{
// calculate the model matrix for each object and pass it to shader before drawing
glm::mat4 model;
glm::mat4 model = glm::mat4(1.0f);
model = glm::translate(model, cubePositions[i]);
float angle = 20.0f * i;
model = glm::rotate(model, glm::radians(angle), glm::vec3(1.0f, 0.3f, 0.5f));
@@ -305,7 +305,7 @@ int main()
glBindVertexArray(lightVAO);
for (unsigned int i = 0; i < 4; i++)
{
model = glm::mat4();
model = glm::mat4(1.0f);
model = glm::translate(model, pointLightPositions[i]);
model = glm::scale(model, glm::vec3(0.2f)); // Make it a smaller cube
lampShader.setMat4("model", model);

View File

@@ -114,7 +114,7 @@ int main()
ourShader.setMat4("view", view);
// render the loaded model
glm::mat4 model;
glm::mat4 model = glm::mat4(1.0f);
model = glm::translate(model, glm::vec3(0.0f, -1.75f, 0.0f)); // translate it down so it's at the center of the scene
model = glm::scale(model, glm::vec3(0.2f, 0.2f, 0.2f)); // it's a bit too big for our scene, so scale it down
ourShader.setMat4("model", model);

View File

@@ -191,7 +191,7 @@ int main()
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
shader.use();
glm::mat4 model;
glm::mat4 model = glm::mat4(1.0f);
glm::mat4 view = camera.GetViewMatrix();
glm::mat4 projection = glm::perspective(glm::radians(camera.Zoom), (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 100.0f);
shader.setMat4("view", view);
@@ -203,14 +203,14 @@ int main()
model = glm::translate(model, glm::vec3(-1.0f, 0.0f, -1.0f));
shader.setMat4("model", model);
glDrawArrays(GL_TRIANGLES, 0, 36);
model = glm::mat4();
model = glm::mat4(1.0f);
model = glm::translate(model, glm::vec3(2.0f, 0.0f, 0.0f));
shader.setMat4("model", model);
glDrawArrays(GL_TRIANGLES, 0, 36);
// floor
glBindVertexArray(planeVAO);
glBindTexture(GL_TEXTURE_2D, floorTexture);
shader.setMat4("model", glm::mat4());
shader.setMat4("model", glm::mat4(1.0f));
glDrawArrays(GL_TRIANGLES, 0, 6);
glBindVertexArray(0);

View File

@@ -191,7 +191,7 @@ int main()
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
shader.use();
glm::mat4 model;
glm::mat4 model = glm::mat4(1.0f);
glm::mat4 view = camera.GetViewMatrix();
glm::mat4 projection = glm::perspective(glm::radians(camera.Zoom), (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 100.0f);
shader.setMat4("view", view);
@@ -203,14 +203,14 @@ int main()
model = glm::translate(model, glm::vec3(-1.0f, 0.0f, -1.0f));
shader.setMat4("model", model);
glDrawArrays(GL_TRIANGLES, 0, 36);
model = glm::mat4();
model = glm::mat4(1.0f);
model = glm::translate(model, glm::vec3(2.0f, 0.0f, 0.0f));
shader.setMat4("model", model);
glDrawArrays(GL_TRIANGLES, 0, 36);
// floor
glBindVertexArray(planeVAO);
glBindTexture(GL_TEXTURE_2D, floorTexture);
shader.setMat4("model", glm::mat4());
shader.setMat4("model", glm::mat4(1.0f));
glDrawArrays(GL_TRIANGLES, 0, 6);
glBindVertexArray(0);

View File

@@ -93,7 +93,7 @@ int main()
float offset = 2.5f;
for (unsigned int i = 0; i < amount; i++)
{
glm::mat4 model;
glm::mat4 model = glm::mat4(1.0f);
// 1. translation: displace along circle with 'radius' in range [-offset, offset]
float angle = (float)i / (float)amount * 360.0f;
float displacement = (rand() % (int)(2 * offset * 100)) / 100.0f - offset;
@@ -143,7 +143,7 @@ int main()
shader.setMat4("view", view);
// draw planet
glm::mat4 model;
glm::mat4 model = glm::mat4(1.0f);
model = glm::translate(model, glm::vec3(0.0f, -3.0f, 0.0f));
model = glm::scale(model, glm::vec3(4.0f, 4.0f, 4.0f));
shader.setMat4("model", model);

View File

@@ -94,7 +94,7 @@ int main()
float offset = 25.0f;
for (unsigned int i = 0; i < amount; i++)
{
glm::mat4 model;
glm::mat4 model = glm::mat4(1.0f);
// 1. translation: displace along circle with 'radius' in range [-offset, offset]
float angle = (float)i / (float)amount * 360.0f;
float displacement = (rand() % (int)(2 * offset * 100)) / 100.0f - offset;
@@ -180,7 +180,7 @@ int main()
planetShader.setMat4("view", view);
// draw planet
glm::mat4 model;
glm::mat4 model = glm::mat4(1.0f);
model = glm::translate(model, glm::vec3(0.0f, -3.0f, 0.0f));
model = glm::scale(model, glm::vec3(4.0f, 4.0f, 4.0f));
planetShader.setMat4("model", model);

View File

@@ -233,7 +233,7 @@ int main()
glm::mat4 projection = glm::perspective(glm::radians(camera.Zoom), (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 1000.0f);
shader.setMat4("projection", projection);
shader.setMat4("view", camera.GetViewMatrix());
shader.setMat4("model", glm::mat4());
shader.setMat4("model", glm::mat4(1.0f));
glBindVertexArray(cubeVAO);
glDrawArrays(GL_TRIANGLES, 0, 36);

View File

@@ -196,7 +196,7 @@ int main()
// set uniforms
shaderSingleColor.use();
glm::mat4 model;
glm::mat4 model = glm::mat4(1.0f);
glm::mat4 view = camera.GetViewMatrix();
glm::mat4 projection = glm::perspective(glm::radians(camera.Zoom), (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 100.0f);
shaderSingleColor.setMat4("view", view);
@@ -211,7 +211,7 @@ int main()
// floor
glBindVertexArray(planeVAO);
glBindTexture(GL_TEXTURE_2D, floorTexture);
shader.setMat4("model", glm::mat4());
shader.setMat4("model", glm::mat4(1.0f));
glDrawArrays(GL_TRIANGLES, 0, 6);
glBindVertexArray(0);
@@ -226,7 +226,7 @@ int main()
model = glm::translate(model, glm::vec3(-1.0f, 0.0f, -1.0f));
shader.setMat4("model", model);
glDrawArrays(GL_TRIANGLES, 0, 36);
model = glm::mat4();
model = glm::mat4(1.0f);
model = glm::translate(model, glm::vec3(2.0f, 0.0f, 0.0f));
shader.setMat4("model", model);
glDrawArrays(GL_TRIANGLES, 0, 36);
@@ -243,12 +243,12 @@ int main()
// cubes
glBindVertexArray(cubeVAO);
glBindTexture(GL_TEXTURE_2D, cubeTexture);
model = glm::mat4();
model = glm::mat4(1.0f);
model = glm::translate(model, glm::vec3(-1.0f, 0.0f, -1.0f));
model = glm::scale(model, glm::vec3(scale, scale, scale));
shaderSingleColor.setMat4("model", model);
glDrawArrays(GL_TRIANGLES, 0, 36);
model = glm::mat4();
model = glm::mat4(1.0f);
model = glm::translate(model, glm::vec3(2.0f, 0.0f, 0.0f));
model = glm::scale(model, glm::vec3(scale, scale, scale));
shaderSingleColor.setMat4("model", model);

View File

@@ -225,7 +225,7 @@ int main()
shader.use();
glm::mat4 projection = glm::perspective(glm::radians(camera.Zoom), (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 100.0f);
glm::mat4 view = camera.GetViewMatrix();
glm::mat4 model;
glm::mat4 model = glm::mat4(1.0f);
shader.setMat4("projection", projection);
shader.setMat4("view", view);
// cubes
@@ -235,14 +235,14 @@ int main()
model = glm::translate(model, glm::vec3(-1.0f, 0.0f, -1.0f));
shader.setMat4("model", model);
glDrawArrays(GL_TRIANGLES, 0, 36);
model = glm::mat4();
model = glm::mat4(1.0f);
model = glm::translate(model, glm::vec3(2.0f, 0.0f, 0.0f));
shader.setMat4("model", model);
glDrawArrays(GL_TRIANGLES, 0, 36);
// floor
glBindVertexArray(planeVAO);
glBindTexture(GL_TEXTURE_2D, floorTexture);
model = glm::mat4();
model = glm::mat4(1.0f);
shader.setMat4("model", model);
glDrawArrays(GL_TRIANGLES, 0, 6);
// vegetation
@@ -250,7 +250,7 @@ int main()
glBindTexture(GL_TEXTURE_2D, transparentTexture);
for (GLuint i = 0; i < vegetation.size(); i++)
{
model = glm::mat4();
model = glm::mat4(1.0f);
model = glm::translate(model, vegetation[i]);
shader.setMat4("model", model);
glDrawArrays(GL_TRIANGLES, 0, 6);

View File

@@ -236,7 +236,7 @@ int main()
shader.use();
glm::mat4 projection = glm::perspective(glm::radians(camera.Zoom), (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 100.0f);
glm::mat4 view = camera.GetViewMatrix();
glm::mat4 model;
glm::mat4 model = glm::mat4(1.0f);
shader.setMat4("projection", projection);
shader.setMat4("view", view);
// cubes
@@ -246,14 +246,14 @@ int main()
model = glm::translate(model, glm::vec3(-1.0f, 0.0f, -1.0f));
shader.setMat4("model", model);
glDrawArrays(GL_TRIANGLES, 0, 36);
model = glm::mat4();
model = glm::mat4(1.0f);
model = glm::translate(model, glm::vec3(2.0f, 0.0f, 0.0f));
shader.setMat4("model", model);
glDrawArrays(GL_TRIANGLES, 0, 36);
// floor
glBindVertexArray(planeVAO);
glBindTexture(GL_TEXTURE_2D, floorTexture);
model = glm::mat4();
model = glm::mat4(1.0f);
shader.setMat4("model", model);
glDrawArrays(GL_TRIANGLES, 0, 6);
// windows (from furthest to nearest)
@@ -261,7 +261,7 @@ int main()
glBindTexture(GL_TEXTURE_2D, transparentTexture);
for (std::map<float, glm::vec3>::reverse_iterator it = sorted.rbegin(); it != sorted.rend(); ++it)
{
model = glm::mat4();
model = glm::mat4(1.0f);
model = glm::translate(model, it->second);
shader.setMat4("model", model);
glDrawArrays(GL_TRIANGLES, 0, 6);

View File

@@ -246,7 +246,7 @@ int main()
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
shader.use();
glm::mat4 model;
glm::mat4 model = glm::mat4(1.0f);
glm::mat4 view = camera.GetViewMatrix();
glm::mat4 projection = glm::perspective(glm::radians(camera.Zoom), (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 100.0f);
shader.setMat4("view", view);
@@ -258,14 +258,14 @@ int main()
model = glm::translate(model, glm::vec3(-1.0f, 0.0f, -1.0f));
shader.setMat4("model", model);
glDrawArrays(GL_TRIANGLES, 0, 36);
model = glm::mat4();
model = glm::mat4(1.0f);
model = glm::translate(model, glm::vec3(2.0f, 0.0f, 0.0f));
shader.setMat4("model", model);
glDrawArrays(GL_TRIANGLES, 0, 36);
// floor
glBindVertexArray(planeVAO);
glBindTexture(GL_TEXTURE_2D, floorTexture);
shader.setMat4("model", glm::mat4());
shader.setMat4("model", glm::mat4(1.0f));
glDrawArrays(GL_TRIANGLES, 0, 6);
glBindVertexArray(0);

View File

@@ -248,7 +248,7 @@ int main()
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
shader.use();
glm::mat4 model;
glm::mat4 model = glm::mat4(1.0f);
camera.Yaw += 180.0f; // rotate the camera's yaw 180 degrees around
camera.Pitch += 180.0f; // rotate the camera's pitch 180 degrees around
camera.ProcessMouseMovement(0, 0, false); // call this to make sure it updates its camera vectors, note that we disable pitch constrains for this specific case (otherwise we can't reverse camera's pitch values)
@@ -266,14 +266,14 @@ int main()
model = glm::translate(model, glm::vec3(-1.0f, 0.0f, -1.0f));
shader.setMat4("model", model);
glDrawArrays(GL_TRIANGLES, 0, 36);
model = glm::mat4();
model = glm::mat4(1.0f);
model = glm::translate(model, glm::vec3(2.0f, 0.0f, 0.0f));
shader.setMat4("model", model);
glDrawArrays(GL_TRIANGLES, 0, 36);
// floor
glBindVertexArray(planeVAO);
glBindTexture(GL_TEXTURE_2D, floorTexture);
shader.setMat4("model", glm::mat4());
shader.setMat4("model", glm::mat4(1.0f));
glDrawArrays(GL_TRIANGLES, 0, 6);
glBindVertexArray(0);
@@ -284,7 +284,7 @@ int main()
glClearColor(0.1f, 0.1f, 0.1f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
model = glm::mat4();
model = glm::mat4(1.0f);
view = camera.GetViewMatrix();
shader.setMat4("view", view);
@@ -295,14 +295,14 @@ int main()
model = glm::translate(model, glm::vec3(-1.0f, 0.0f, -1.0f));
shader.setMat4("model", model);
glDrawArrays(GL_TRIANGLES, 0, 36);
model = glm::mat4();
model = glm::mat4(1.0f);
model = glm::translate(model, glm::vec3(2.0f, 0.0f, 0.0f));
shader.setMat4("model", model);
glDrawArrays(GL_TRIANGLES, 0, 36);
// floor
glBindVertexArray(planeVAO);
glBindTexture(GL_TEXTURE_2D, floorTexture);
shader.setMat4("model", glm::mat4());
shader.setMat4("model", glm::mat4(1.0f));
glDrawArrays(GL_TRIANGLES, 0, 6);
glBindVertexArray(0);

View File

@@ -237,7 +237,7 @@ int main()
// draw scene as normal
shader.use();
glm::mat4 model;
glm::mat4 model = glm::mat4(1.0f);
glm::mat4 view = camera.GetViewMatrix();
glm::mat4 projection = glm::perspective(glm::radians(camera.Zoom), (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 100.0f);
shader.setMat4("model", model);

View File

@@ -235,7 +235,7 @@ int main()
// draw scene as normal
shader.use();
glm::mat4 model;
glm::mat4 model = glm::mat4(1.0f);
glm::mat4 view = camera.GetViewMatrix();
glm::mat4 projection = glm::perspective(glm::radians(camera.Zoom), (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 100.0f);
shader.setMat4("model", model);

View File

@@ -191,25 +191,25 @@ int main()
// RED
glBindVertexArray(cubeVAO);
shaderRed.use();
glm::mat4 model;
glm::mat4 model = glm::mat4(1.0f);
model = glm::translate(model, glm::vec3(-0.75f, 0.75f, 0.0f)); // move top-left
shaderRed.setMat4("model", model);
glDrawArrays(GL_TRIANGLES, 0, 36);
// GREEN
shaderGreen.use();
model = glm::mat4();
model = glm::mat4(1.0f);
model = glm::translate(model, glm::vec3(0.75f, 0.75f, 0.0f)); // move top-right
shaderGreen.setMat4("model", model);
glDrawArrays(GL_TRIANGLES, 0, 36);
// YELLOW
shaderYellow.use();
model = glm::mat4();
model = glm::mat4(1.0f);
model = glm::translate(model, glm::vec3(-0.75f, -0.75f, 0.0f)); // move bottom-left
shaderYellow.setMat4("model", model);
glDrawArrays(GL_TRIANGLES, 0, 36);
// BLUE
shaderBlue.use();
model = glm::mat4();
model = glm::mat4(1.0f);
model = glm::translate(model, glm::vec3(0.75f, -0.75f, 0.0f)); // move bottom-right
shaderBlue.setMat4("model", model);
glDrawArrays(GL_TRIANGLES, 0, 36);

View File

@@ -104,7 +104,7 @@ int main()
// configure transformation matrices
glm::mat4 projection = glm::perspective(glm::radians(45.0f), (float)SCR_WIDTH / (float)SCR_HEIGHT, 1.0f, 100.0f);
glm::mat4 view = camera.GetViewMatrix();;
glm::mat4 model;
glm::mat4 model = glm::mat4(1.0f);
shader.use();
shader.setMat4("projection", projection);
shader.setMat4("view", view);

View File

@@ -105,7 +105,7 @@ int main()
// configure transformation matrices
glm::mat4 projection = glm::perspective(glm::radians(45.0f), (float)SCR_WIDTH / (float)SCR_HEIGHT, 1.0f, 100.0f);
glm::mat4 view = camera.GetViewMatrix();;
glm::mat4 model;
glm::mat4 model = glm::mat4(1.0f);
shader.use();
shader.setMat4("projection", projection);
shader.setMat4("view", view);

View File

@@ -220,22 +220,22 @@ int main()
void renderScene(const Shader &shader)
{
// floor
glm::mat4 model;
glm::mat4 model = glm::mat4(1.0f);
shader.setMat4("model", model);
glBindVertexArray(planeVAO);
glDrawArrays(GL_TRIANGLES, 0, 6);
// cubes
model = glm::mat4();
model = glm::mat4(1.0f);
model = glm::translate(model, glm::vec3(0.0f, 1.5f, 0.0));
model = glm::scale(model, glm::vec3(0.5f));
shader.setMat4("model", model);
renderCube();
model = glm::mat4();
model = glm::mat4(1.0f);
model = glm::translate(model, glm::vec3(2.0f, 0.0f, 1.0));
model = glm::scale(model, glm::vec3(0.5f));
shader.setMat4("model", model);
renderCube();
model = glm::mat4();
model = glm::mat4(1.0f);
model = glm::translate(model, glm::vec3(-1.0f, 0.0f, 2.0));
model = glm::rotate(model, glm::radians(60.0f), glm::normalize(glm::vec3(1.0, 0.0, 1.0)));
model = glm::scale(model, glm::vec3(0.25));

View File

@@ -243,22 +243,22 @@ int main()
void renderScene(const Shader &shader)
{
// floor
glm::mat4 model;
glm::mat4 model = glm::mat4(1.0f);
shader.setMat4("model", model);
glBindVertexArray(planeVAO);
glDrawArrays(GL_TRIANGLES, 0, 6);
// cubes
model = glm::mat4();
model = glm::mat4(1.0f);
model = glm::translate(model, glm::vec3(0.0f, 1.5f, 0.0));
model = glm::scale(model, glm::vec3(0.5f));
shader.setMat4("model", model);
renderCube();
model = glm::mat4();
model = glm::mat4(1.0f);
model = glm::translate(model, glm::vec3(2.0f, 0.0f, 1.0));
model = glm::scale(model, glm::vec3(0.5f));
shader.setMat4("model", model);
renderCube();
model = glm::mat4();
model = glm::mat4(1.0f);
model = glm::translate(model, glm::vec3(-1.0f, 0.0f, 2.0));
model = glm::rotate(model, glm::radians(60.0f), glm::normalize(glm::vec3(1.0, 0.0, 1.0)));
model = glm::scale(model, glm::vec3(0.25));

View File

@@ -251,22 +251,22 @@ int main()
void renderScene(const Shader &shader)
{
// floor
glm::mat4 model;
glm::mat4 model = glm::mat4(1.0f);
shader.setMat4("model", model);
glBindVertexArray(planeVAO);
glDrawArrays(GL_TRIANGLES, 0, 6);
// cubes
model = glm::mat4();
model = glm::mat4(1.0f);
model = glm::translate(model, glm::vec3(0.0f, 1.5f, 0.0));
model = glm::scale(model, glm::vec3(0.5f));
shader.setMat4("model", model);
renderCube();
model = glm::mat4();
model = glm::mat4(1.0f);
model = glm::translate(model, glm::vec3(2.0f, 0.0f, 1.0));
model = glm::scale(model, glm::vec3(0.5f));
shader.setMat4("model", model);
renderCube();
model = glm::mat4();
model = glm::mat4(1.0f);
model = glm::translate(model, glm::vec3(-1.0f, 0.0f, 2.0));
model = glm::rotate(model, glm::radians(60.0f), glm::normalize(glm::vec3(1.0, 0.0, 1.0)));
model = glm::scale(model, glm::vec3(0.25));

View File

@@ -206,7 +206,7 @@ int main()
void renderScene(const Shader &shader)
{
// room cube
glm::mat4 model;
glm::mat4 model = glm::mat4(1.0f);
model = glm::scale(model, glm::vec3(5.0f));
shader.setMat4("model", model);
glDisable(GL_CULL_FACE); // note that we disable culling here since we render 'inside' the cube instead of the usual 'outside' which throws off the normal culling methods.
@@ -215,27 +215,27 @@ void renderScene(const Shader &shader)
shader.setInt("reverse_normals", 0); // and of course disable it
glEnable(GL_CULL_FACE);
// cubes
model = glm::mat4();
model = glm::mat4(1.0f);
model = glm::translate(model, glm::vec3(4.0f, -3.5f, 0.0));
model = glm::scale(model, glm::vec3(0.5f));
shader.setMat4("model", model);
renderCube();
model = glm::mat4();
model = glm::mat4(1.0f);
model = glm::translate(model, glm::vec3(2.0f, 3.0f, 1.0));
model = glm::scale(model, glm::vec3(0.75f));
shader.setMat4("model", model);
renderCube();
model = glm::mat4();
model = glm::mat4(1.0f);
model = glm::translate(model, glm::vec3(-3.0f, -1.0f, 0.0));
model = glm::scale(model, glm::vec3(0.5f));
shader.setMat4("model", model);
renderCube();
model = glm::mat4();
model = glm::mat4(1.0f);
model = glm::translate(model, glm::vec3(-1.5f, 1.0f, 1.5));
model = glm::scale(model, glm::vec3(0.5f));
shader.setMat4("model", model);
renderCube();
model = glm::mat4();
model = glm::mat4(1.0f);
model = glm::translate(model, glm::vec3(-1.5f, 2.0f, -3.0));
model = glm::rotate(model, glm::radians(60.0f), glm::normalize(glm::vec3(1.0, 0.0, 1.0)));
model = glm::scale(model, glm::vec3(0.75f));

View File

@@ -206,7 +206,7 @@ int main()
void renderScene(const Shader &shader)
{
// room cube
glm::mat4 model;
glm::mat4 model = glm::mat4(1.0f);
model = glm::scale(model, glm::vec3(5.0f));
shader.setMat4("model", model);
glDisable(GL_CULL_FACE); // note that we disable culling here since we render 'inside' the cube instead of the usual 'outside' which throws off the normal culling methods.
@@ -215,27 +215,27 @@ void renderScene(const Shader &shader)
shader.setInt("reverse_normals", 0); // and of course disable it
glEnable(GL_CULL_FACE);
// cubes
model = glm::mat4();
model = glm::mat4(1.0f);
model = glm::translate(model, glm::vec3(4.0f, -3.5f, 0.0));
model = glm::scale(model, glm::vec3(0.5f));
shader.setMat4("model", model);
renderCube();
model = glm::mat4();
model = glm::mat4(1.0f);
model = glm::translate(model, glm::vec3(2.0f, 3.0f, 1.0));
model = glm::scale(model, glm::vec3(0.75f));
shader.setMat4("model", model);
renderCube();
model = glm::mat4();
model = glm::mat4(1.0f);
model = glm::translate(model, glm::vec3(-3.0f, -1.0f, 0.0));
model = glm::scale(model, glm::vec3(0.5f));
shader.setMat4("model", model);
renderCube();
model = glm::mat4();
model = glm::mat4(1.0f);
model = glm::translate(model, glm::vec3(-1.5f, 1.0f, 1.5));
model = glm::scale(model, glm::vec3(0.5f));
shader.setMat4("model", model);
renderCube();
model = glm::mat4();
model = glm::mat4(1.0f);
model = glm::translate(model, glm::vec3(-1.5f, 2.0f, -3.0));
model = glm::rotate(model, glm::radians(60.0f), glm::normalize(glm::vec3(1.0, 0.0, 1.0)));
model = glm::scale(model, glm::vec3(0.75f));

View File

@@ -121,7 +121,7 @@ int main()
shader.setMat4("projection", projection);
shader.setMat4("view", view);
// render normal-mapped quad
glm::mat4 model;
glm::mat4 model = glm::mat4(1.0f);
model = glm::rotate(model, glm::radians((float)glfwGetTime() * -10.0f), glm::normalize(glm::vec3(1.0, 0.0, 1.0))); // rotate the quad to show normal mapping from multiple directions
shader.setMat4("model", model);
shader.setVec3("viewPos", camera.Position);
@@ -133,7 +133,7 @@ int main()
renderQuad();
// render light source (simply re-renders a smaller plane at the light's position for debugging/visualization)
model = glm::mat4();
model = glm::mat4(1.0f);
model = glm::translate(model, lightPos);
model = glm::scale(model, glm::vec3(0.1f));
shader.setMat4("model", model);

View File

@@ -127,7 +127,7 @@ int main()
shader.setMat4("projection", projection);
shader.setMat4("view", view);
// render parallax-mapped quad
glm::mat4 model;
glm::mat4 model = glm::mat4(1.0f);
model = glm::rotate(model, glm::radians((float)glfwGetTime() * -10.0f), glm::normalize(glm::vec3(1.0, 0.0, 1.0))); // rotate the quad to show parallax mapping from multiple directions
shader.setMat4("model", model);
shader.setVec3("viewPos", camera.Position);
@@ -143,7 +143,7 @@ int main()
renderQuad();
// render light source (simply re-renders a smaller plane at the light's position for debugging/visualization)
model = glm::mat4();
model = glm::mat4(1.0f);
model = glm::translate(model, lightPos);
model = glm::scale(model, glm::vec3(0.1f));
shader.setMat4("model", model);

View File

@@ -127,7 +127,7 @@ int main()
shader.setMat4("projection", projection);
shader.setMat4("view", view);
// render parallax-mapped quad
glm::mat4 model;
glm::mat4 model = glm::mat4(1.0f);
model = glm::rotate(model, glm::radians((float)glfwGetTime() * -10.0f), glm::normalize(glm::vec3(1.0, 0.0, 1.0))); // rotate the quad to show parallax mapping from multiple directions
shader.setMat4("model", model);
shader.setVec3("viewPos", camera.Position);
@@ -143,7 +143,7 @@ int main()
renderQuad();
// render light source (simply re-renders a smaller plane at the light's position for debugging/visualization)
model = glm::mat4();
model = glm::mat4(1.0f);
model = glm::translate(model, lightPos);
model = glm::scale(model, glm::vec3(0.1f));
shader.setMat4("model", model);

View File

@@ -127,7 +127,7 @@ int main()
shader.setMat4("projection", projection);
shader.setMat4("view", view);
// render parallax-mapped quad
glm::mat4 model;
glm::mat4 model = glm::mat4(1.0f);
model = glm::rotate(model, glm::radians((float)glfwGetTime() * -10.0f), glm::normalize(glm::vec3(1.0, 0.0, 1.0))); // rotate the quad to show parallax mapping from multiple directions
shader.setMat4("model", model);
shader.setVec3("viewPos", camera.Position);
@@ -143,7 +143,7 @@ int main()
renderQuad();
// render light source (simply re-renders a smaller plane at the light's position for debugging/visualization)
model = glm::mat4();
model = glm::mat4(1.0f);
model = glm::translate(model, lightPos);
model = glm::scale(model, glm::vec3(0.1f));
shader.setMat4("model", model);

View File

@@ -173,7 +173,7 @@ int main()
}
shader.setVec3("viewPos", camera.Position);
// render tunnel
glm::mat4 model = glm::mat4();
glm::mat4 model = glm::mat4(1.0f);
model = glm::translate(model, glm::vec3(0.0f, 0.0f, 25.0));
model = glm::scale(model, glm::vec3(2.5f, 2.5f, 27.5f));
shader.setMat4("model", model);

View File

@@ -196,7 +196,7 @@ int main()
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glm::mat4 projection = glm::perspective(glm::radians(camera.Zoom), (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 100.0f);
glm::mat4 view = camera.GetViewMatrix();
glm::mat4 model;
glm::mat4 model = glm::mat4(1.0f);
shader.use();
shader.setMat4("projection", projection);
shader.setMat4("view", view);
@@ -210,7 +210,7 @@ int main()
}
shader.setVec3("viewPos", camera.Position);
// create one large cube that acts as the floor
model = glm::mat4();
model = glm::mat4(1.0f);
model = glm::translate(model, glm::vec3(0.0f, -1.0f, 0.0));
model = glm::scale(model, glm::vec3(12.5f, 0.5f, 12.5f));
shader.setMat4("model", model);
@@ -218,38 +218,38 @@ int main()
renderCube();
// then create multiple cubes as the scenery
glBindTexture(GL_TEXTURE_2D, containerTexture);
model = glm::mat4();
model = glm::mat4(1.0f);
model = glm::translate(model, glm::vec3(0.0f, 1.5f, 0.0));
model = glm::scale(model, glm::vec3(0.5f));
shader.setMat4("model", model);
renderCube();
model = glm::mat4();
model = glm::mat4(1.0f);
model = glm::translate(model, glm::vec3(2.0f, 0.0f, 1.0));
model = glm::scale(model, glm::vec3(0.5f));
shader.setMat4("model", model);
renderCube();
model = glm::mat4();
model = glm::mat4(1.0f);
model = glm::translate(model, glm::vec3(-1.0f, -1.0f, 2.0));
model = glm::rotate(model, glm::radians(60.0f), glm::normalize(glm::vec3(1.0, 0.0, 1.0)));
shader.setMat4("model", model);
renderCube();
model = glm::mat4();
model = glm::mat4(1.0f);
model = glm::translate(model, glm::vec3(0.0f, 2.7f, 4.0));
model = glm::rotate(model, glm::radians(23.0f), glm::normalize(glm::vec3(1.0, 0.0, 1.0)));
model = glm::scale(model, glm::vec3(1.25));
shader.setMat4("model", model);
renderCube();
model = glm::mat4();
model = glm::mat4(1.0f);
model = glm::translate(model, glm::vec3(-2.0f, 1.0f, -3.0));
model = glm::rotate(model, glm::radians(124.0f), glm::normalize(glm::vec3(1.0, 0.0, 1.0)));
shader.setMat4("model", model);
renderCube();
model = glm::mat4();
model = glm::mat4(1.0f);
model = glm::translate(model, glm::vec3(-3.0f, 0.0f, 0.0));
model = glm::scale(model, glm::vec3(0.5f));
shader.setMat4("model", model);
@@ -262,7 +262,7 @@ int main()
for (unsigned int i = 0; i < lightPositions.size(); i++)
{
model = glm::mat4();
model = glm::mat4(1.0f);
model = glm::translate(model, glm::vec3(lightPositions[i]));
model = glm::scale(model, glm::vec3(0.25f));
shaderLight.setMat4("model", model);

View File

@@ -190,13 +190,13 @@ int main()
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glm::mat4 projection = glm::perspective(glm::radians(camera.Zoom), (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 100.0f);
glm::mat4 view = camera.GetViewMatrix();
glm::mat4 model;
glm::mat4 model = glm::mat4(1.0f);
shaderGeometryPass.use();
shaderGeometryPass.setMat4("projection", projection);
shaderGeometryPass.setMat4("view", view);
for (unsigned int i = 0; i < objectPositions.size(); i++)
{
model = glm::mat4();
model = glm::mat4(1.0f);
model = glm::translate(model, objectPositions[i]);
model = glm::scale(model, glm::vec3(0.25f));
shaderGeometryPass.setMat4("model", model);
@@ -247,7 +247,7 @@ int main()
shaderLightBox.setMat4("view", view);
for (unsigned int i = 0; i < lightPositions.size(); i++)
{
model = glm::mat4();
model = glm::mat4(1.0f);
model = glm::translate(model, lightPositions[i]);
model = glm::scale(model, glm::vec3(0.125f));
shaderLightBox.setMat4("model", model);

View File

@@ -190,13 +190,13 @@ int main()
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glm::mat4 projection = glm::perspective(glm::radians(camera.Zoom), (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 100.0f);
glm::mat4 view = camera.GetViewMatrix();
glm::mat4 model;
glm::mat4 model = glm::mat4(1.0f);
shaderGeometryPass.use();
shaderGeometryPass.setMat4("projection", projection);
shaderGeometryPass.setMat4("view", view);
for (unsigned int i = 0; i < objectPositions.size(); i++)
{
model = glm::mat4();
model = glm::mat4(1.0f);
model = glm::translate(model, objectPositions[i]);
model = glm::scale(model, glm::vec3(0.25f));
shaderGeometryPass.setMat4("model", model);
@@ -251,7 +251,7 @@ int main()
shaderLightBox.setMat4("view", view);
for (unsigned int i = 0; i < lightPositions.size(); i++)
{
model = glm::mat4();
model = glm::mat4(1.0f);
model = glm::translate(model, lightPositions[i]);
model = glm::scale(model, glm::vec3(0.125f));
shaderLightBox.setMat4("model", model);

View File

@@ -241,12 +241,12 @@ int main()
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glm::mat4 projection = glm::perspective(glm::radians(camera.Zoom), (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 50.0f);
glm::mat4 view = camera.GetViewMatrix();
glm::mat4 model;
glm::mat4 model = glm::mat4(1.0f);
shaderGeometryPass.use();
shaderGeometryPass.setMat4("projection", projection);
shaderGeometryPass.setMat4("view", view);
// room cube
model = glm::mat4();
model = glm::mat4(1.0f);
model = glm::translate(model, glm::vec3(0.0, 7.0f, 0.0f));
model = glm::scale(model, glm::vec3(7.5f, 7.5f, 7.5f));
shaderGeometryPass.setMat4("model", model);
@@ -254,7 +254,7 @@ int main()
renderCube();
shaderGeometryPass.setInt("invertedNormals", 0);
// nanosuit model on the floor
model = glm::mat4();
model = glm::mat4(1.0f);
model = glm::translate(model, glm::vec3(0.0f, 0.0f, 5.0));
model = glm::rotate(model, glm::radians(-90.0f), glm::vec3(1.0, 0.0, 0.0));
model = glm::scale(model, glm::vec3(0.5f));

View File

@@ -134,7 +134,7 @@ int main()
shader.setVec3("camPos", camera.Position);
// render rows*column number of spheres with varying metallic/roughness values scaled by rows and columns respectively
glm::mat4 model;
glm::mat4 model = glm::mat4(1.0f);
for (int row = 0; row < nrRows; ++row)
{
shader.setFloat("metallic", (float)row / (float)nrRows);
@@ -144,7 +144,7 @@ int main()
// on direct lighting.
shader.setFloat("roughness", glm::clamp((float)col / (float)nrColumns, 0.05f, 1.0f));
model = glm::mat4();
model = glm::mat4(1.0f);
model = glm::translate(model, glm::vec3(
(col - (nrColumns / 2)) * spacing,
(row - (nrRows / 2)) * spacing,
@@ -165,7 +165,7 @@ int main()
shader.setVec3("lightPositions[" + std::to_string(i) + "]", newPos);
shader.setVec3("lightColors[" + std::to_string(i) + "]", lightColors[i]);
model = glm::mat4();
model = glm::mat4(1.0f);
model = glm::translate(model, newPos);
model = glm::scale(model, glm::vec3(0.5f));
shader.setMat4("model", model);

View File

@@ -150,12 +150,12 @@ int main()
glBindTexture(GL_TEXTURE_2D, ao);
// render rows*column number of spheres with material properties defined by textures (they all have the same material properties)
glm::mat4 model;
glm::mat4 model = glm::mat4(1.0f);
for (int row = 0; row < nrRows; ++row)
{
for (int col = 0; col < nrColumns; ++col)
{
model = glm::mat4();
model = glm::mat4(1.0f);
model = glm::translate(model, glm::vec3(
(float)(col - (nrColumns / 2)) * spacing,
(float)(row - (nrRows / 2)) * spacing,
@@ -176,7 +176,7 @@ int main()
shader.setVec3("lightPositions[" + std::to_string(i) + "]", newPos);
shader.setVec3("lightColors[" + std::to_string(i) + "]", lightColors[i]);
model = glm::mat4();
model = glm::mat4(1.0f);
model = glm::translate(model, newPos);
model = glm::scale(model, glm::vec3(0.5f));
shader.setMat4("model", model);

View File

@@ -235,7 +235,7 @@ int main()
pbrShader.setVec3("camPos", camera.Position);
// render rows*column number of spheres with material properties defined by textures (they all have the same material properties)
glm::mat4 model;
glm::mat4 model = glm::mat4(1.0f);
for (int row = 0; row < nrRows; ++row)
{
pbrShader.setFloat("metallic", (float)row / (float)nrRows);
@@ -245,7 +245,7 @@ int main()
// on direct lighting.
pbrShader.setFloat("roughness", glm::clamp((float)col / (float)nrColumns, 0.05f, 1.0f));
model = glm::mat4();
model = glm::mat4(1.0f);
model = glm::translate(model, glm::vec3(
(float)(col - (nrColumns / 2)) * spacing,
(float)(row - (nrRows / 2)) * spacing,
@@ -267,7 +267,7 @@ int main()
pbrShader.setVec3("lightPositions[" + std::to_string(i) + "]", newPos);
pbrShader.setVec3("lightColors[" + std::to_string(i) + "]", lightColors[i]);
model = glm::mat4();
model = glm::mat4(1.0f);
model = glm::translate(model, newPos);
model = glm::scale(model, glm::vec3(0.5f));
pbrShader.setMat4("model", model);

View File

@@ -280,7 +280,7 @@ int main()
glBindTexture(GL_TEXTURE_CUBE_MAP, irradianceMap);
// render rows*column number of spheres with material properties defined by textures (they all have the same material properties)
glm::mat4 model;
glm::mat4 model = glm::mat4(1.0f);
for (int row = 0; row < nrRows; ++row)
{
pbrShader.setFloat("metallic", (float)row / (float)nrRows);
@@ -290,7 +290,7 @@ int main()
// on direct lighting.
pbrShader.setFloat("roughness", glm::clamp((float)col / (float)nrColumns, 0.05f, 1.0f));
model = glm::mat4();
model = glm::mat4(1.0f);
model = glm::translate(model, glm::vec3(
(float)(col - (nrColumns / 2)) * spacing,
(float)(row - (nrRows / 2)) * spacing,
@@ -312,7 +312,7 @@ int main()
pbrShader.setVec3("lightPositions[" + std::to_string(i) + "]", newPos);
pbrShader.setVec3("lightColors[" + std::to_string(i) + "]", lightColors[i]);
model = glm::mat4();
model = glm::mat4(1.0f);
model = glm::translate(model, newPos);
model = glm::scale(model, glm::vec3(0.5f));
pbrShader.setMat4("model", model);

View File

@@ -372,7 +372,7 @@ int main()
glBindTexture(GL_TEXTURE_2D, brdfLUTTexture);
// render rows*column number of spheres with material properties defined by textures (they all have the same material properties)
glm::mat4 model;
glm::mat4 model = glm::mat4(1.0f);
for (int row = 0; row < nrRows; ++row)
{
pbrShader.setFloat("metallic", (float)row / (float)nrRows);
@@ -382,7 +382,7 @@ int main()
// on direct lighting.
pbrShader.setFloat("roughness", glm::clamp((float)col / (float)nrColumns, 0.05f, 1.0f));
model = glm::mat4();
model = glm::mat4(1.0f);
model = glm::translate(model, glm::vec3(
(float)(col - (nrColumns / 2)) * spacing,
(float)(row - (nrRows / 2)) * spacing,
@@ -404,7 +404,7 @@ int main()
pbrShader.setVec3("lightPositions[" + std::to_string(i) + "]", newPos);
pbrShader.setVec3("lightColors[" + std::to_string(i) + "]", lightColors[i]);
model = glm::mat4();
model = glm::mat4(1.0f);
model = glm::translate(model, newPos);
model = glm::scale(model, glm::vec3(0.5f));
pbrShader.setMat4("model", model);

View File

@@ -399,7 +399,7 @@ int main()
// render scene, supplying the convoluted irradiance map to the final shader.
// ------------------------------------------------------------------------------------------
pbrShader.use();
glm::mat4 model;
glm::mat4 model = glm::mat4(1.0f);
glm::mat4 view = camera.GetViewMatrix();
pbrShader.setMat4("view", view);
pbrShader.setVec3("camPos", camera.Position);
@@ -424,7 +424,7 @@ int main()
glActiveTexture(GL_TEXTURE7);
glBindTexture(GL_TEXTURE_2D, ironAOMap);
model = glm::mat4();
model = glm::mat4(1.0f);
model = glm::translate(model, glm::vec3(-5.0, 0.0, 2.0));
pbrShader.setMat4("model", model);
renderSphere();
@@ -441,7 +441,7 @@ int main()
glActiveTexture(GL_TEXTURE7);
glBindTexture(GL_TEXTURE_2D, goldAOMap);
model = glm::mat4();
model = glm::mat4(1.0f);
model = glm::translate(model, glm::vec3(-3.0, 0.0, 2.0));
pbrShader.setMat4("model", model);
renderSphere();
@@ -458,7 +458,7 @@ int main()
glActiveTexture(GL_TEXTURE7);
glBindTexture(GL_TEXTURE_2D, grassAOMap);
model = glm::mat4();
model = glm::mat4(1.0f);
model = glm::translate(model, glm::vec3(-1.0, 0.0, 2.0));
pbrShader.setMat4("model", model);
renderSphere();
@@ -475,7 +475,7 @@ int main()
glActiveTexture(GL_TEXTURE7);
glBindTexture(GL_TEXTURE_2D, plasticAOMap);
model = glm::mat4();
model = glm::mat4(1.0f);
model = glm::translate(model, glm::vec3(1.0, 0.0, 2.0));
pbrShader.setMat4("model", model);
renderSphere();
@@ -492,7 +492,7 @@ int main()
glActiveTexture(GL_TEXTURE7);
glBindTexture(GL_TEXTURE_2D, wallAOMap);
model = glm::mat4();
model = glm::mat4(1.0f);
model = glm::translate(model, glm::vec3(3.0, 0.0, 2.0));
pbrShader.setMat4("model", model);
renderSphere();
@@ -507,7 +507,7 @@ int main()
pbrShader.setVec3("lightPositions[" + std::to_string(i) + "]", newPos);
pbrShader.setVec3("lightColors[" + std::to_string(i) + "]", lightColors[i]);
model = glm::mat4();
model = glm::mat4(1.0f);
model = glm::translate(model, newPos);
model = glm::scale(model, glm::vec3(0.5f));
pbrShader.setMat4("model", model);

View File

@@ -245,7 +245,7 @@ int main()
shader.use();
GLfloat rotationSpeed = 10.0f;
GLfloat angle = (float)glfwGetTime() * rotationSpeed;
glm::mat4 model;
glm::mat4 model = glm::mat4(1.0f);
model = glm::translate(model, glm::vec3(0.0, 0.0f, -2.5));
model = glm::rotate(model, glm::radians(angle), glm::vec3(1.0f, 1.0f, 1.0f));
glUniformMatrix4fv(glGetUniformLocation(shader.ID, "model"), 1, GL_FALSE, glm::value_ptr(model));