Merge pull request #162 from lnslbrty/master

fixed compiler warnings reported by gcc/clang
This commit is contained in:
Joey de Vries
2020-03-22 12:43:59 +01:00
committed by GitHub
14 changed files with 32 additions and 44 deletions

View File

@@ -53,7 +53,7 @@ public:
geometryCode = gShaderStream.str();
}
}
catch (std::ifstream::failure e)
catch (std::ifstream::failure& e)
{
std::cout << "ERROR::SHADER::FILE_NOT_SUCCESFULLY_READ" << std::endl;
}
@@ -188,4 +188,4 @@ private:
}
}
};
#endif
#endif

View File

@@ -41,7 +41,7 @@ public:
vertexCode = vShaderStream.str();
fragmentCode = fShaderStream.str();
}
catch (std::ifstream::failure e)
catch (std::ifstream::failure& e)
{
std::cout << "ERROR::SHADER::FILE_NOT_SUCCESFULLY_READ" << std::endl;
}
@@ -162,4 +162,4 @@ private:
}
}
};
#endif
#endif

View File

@@ -40,7 +40,7 @@ public:
vertexCode = vShaderStream.str();
fragmentCode = fShaderStream.str();
}
catch (std::ifstream::failure e)
catch (std::ifstream::failure& e)
{
std::cout << "ERROR::SHADER::FILE_NOT_SUCCESFULLY_READ" << std::endl;
}
@@ -118,4 +118,4 @@ private:
}
}
};
#endif
#endif

View File

@@ -41,7 +41,7 @@ int main()
// glfw window creation
// --------------------
GLFWwindow* window = glfwCreateWindow(800, 600, "LearnOpenGL", NULL, NULL);
GLFWwindow* window = glfwCreateWindow(SCR_WIDTH, SCR_HEIGHT, "LearnOpenGL", NULL, NULL);
if (window == NULL)
{
std::cout << "Failed to create GLFW window" << std::endl;

View File

@@ -338,4 +338,4 @@ unsigned int loadTexture(char const * path)
}
return textureID;
}
}

View File

@@ -380,7 +380,6 @@ void processInput(GLFWwindow *window)
if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS)
glfwSetWindowShouldClose(window, true);
float cameraSpeed = 2.5 * deltaTime;
if (glfwGetKey(window, GLFW_KEY_W) == GLFW_PRESS)
camera.ProcessKeyboard(FORWARD, deltaTime);
if (glfwGetKey(window, GLFW_KEY_S) == GLFW_PRESS)

View File

@@ -220,7 +220,6 @@ int main()
shaderLightingPass.setVec3("lights[" + std::to_string(i) + "].Position", lightPositions[i]);
shaderLightingPass.setVec3("lights[" + std::to_string(i) + "].Color", lightColors[i]);
// update attenuation parameters and calculate radius
const float constant = 1.0; // note that we don't send this to the shader, we assume it is always 1.0 (in our case)
const float linear = 0.7;
const float quadratic = 1.8;
shaderLightingPass.setFloat("lights[" + std::to_string(i) + "].Linear", linear);

View File

@@ -302,7 +302,6 @@ int main()
shaderLightingPass.setVec3("light.Position", lightPosView);
shaderLightingPass.setVec3("light.Color", lightColor);
// Update attenuation parameters
const float constant = 1.0; // note that we don't send this to the shader, we assume it is always 1.0 (in our case)
const float linear = 0.09;
const float quadratic = 0.032;
shaderLightingPass.setFloat("light.Linear", linear);

View File

@@ -191,7 +191,6 @@ void processInput(GLFWwindow *window)
if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS)
glfwSetWindowShouldClose(window, true);
float cameraSpeed = 2.5 * deltaTime;
if (glfwGetKey(window, GLFW_KEY_W) == GLFW_PRESS)
camera.ProcessKeyboard(FORWARD, deltaTime);
if (glfwGetKey(window, GLFW_KEY_S) == GLFW_PRESS)
@@ -278,11 +277,11 @@ void renderSphere()
}
bool oddRow = false;
for (int y = 0; y < Y_SEGMENTS; ++y)
for (unsigned int y = 0; y < Y_SEGMENTS; ++y)
{
if (!oddRow) // even rows: y == 0, y == 2; and so on
{
for (int x = 0; x <= X_SEGMENTS; ++x)
for (unsigned int x = 0; x <= X_SEGMENTS; ++x)
{
indices.push_back(y * (X_SEGMENTS + 1) + x);
indices.push_back((y + 1) * (X_SEGMENTS + 1) + x);
@@ -290,7 +289,7 @@ void renderSphere()
}
else
{
for (int x = X_SEGMENTS; x >= 0; --x)
for (unsigned int x = X_SEGMENTS; x >= 0; --x)
{
indices.push_back((y + 1) * (X_SEGMENTS + 1) + x);
indices.push_back(y * (X_SEGMENTS + 1) + x);
@@ -301,7 +300,7 @@ void renderSphere()
indexCount = indices.size();
std::vector<float> data;
for (int i = 0; i < positions.size(); ++i)
for (unsigned int i = 0; i < positions.size(); ++i)
{
data.push_back(positions[i].x);
data.push_back(positions[i].y);

View File

@@ -202,7 +202,6 @@ void processInput(GLFWwindow *window)
if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS)
glfwSetWindowShouldClose(window, true);
float cameraSpeed = 2.5 * deltaTime;
if (glfwGetKey(window, GLFW_KEY_W) == GLFW_PRESS)
camera.ProcessKeyboard(FORWARD, deltaTime);
if (glfwGetKey(window, GLFW_KEY_S) == GLFW_PRESS)
@@ -289,11 +288,11 @@ void renderSphere()
}
bool oddRow = false;
for (int y = 0; y < Y_SEGMENTS; ++y)
for (unsigned int y = 0; y < Y_SEGMENTS; ++y)
{
if (!oddRow) // even rows: y == 0, y == 2; and so on
{
for (int x = 0; x <= X_SEGMENTS; ++x)
for (unsigned int x = 0; x <= X_SEGMENTS; ++x)
{
indices.push_back(y * (X_SEGMENTS + 1) + x);
indices.push_back((y + 1) * (X_SEGMENTS + 1) + x);
@@ -301,7 +300,7 @@ void renderSphere()
}
else
{
for (int x = X_SEGMENTS; x >= 0; --x)
for (unsigned int x = X_SEGMENTS; x >= 0; --x)
{
indices.push_back((y + 1) * (X_SEGMENTS + 1) + x);
indices.push_back(y * (X_SEGMENTS + 1) + x);
@@ -312,7 +311,7 @@ void renderSphere()
indexCount = indices.size();
std::vector<float> data;
for (int i = 0; i < positions.size(); ++i)
for (std::size_t i = 0; i < positions.size(); ++i)
{
data.push_back(positions[i].x);
data.push_back(positions[i].y);

View File

@@ -307,7 +307,6 @@ void processInput(GLFWwindow *window)
if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS)
glfwSetWindowShouldClose(window, true);
float cameraSpeed = 2.5 * deltaTime;
if (glfwGetKey(window, GLFW_KEY_W) == GLFW_PRESS)
camera.ProcessKeyboard(FORWARD, deltaTime);
if (glfwGetKey(window, GLFW_KEY_S) == GLFW_PRESS)
@@ -394,11 +393,11 @@ void renderSphere()
}
bool oddRow = false;
for (int y = 0; y < Y_SEGMENTS; ++y)
for (unsigned int y = 0; y < Y_SEGMENTS; ++y)
{
if (!oddRow) // even rows: y == 0, y == 2; and so on
{
for (int x = 0; x <= X_SEGMENTS; ++x)
for (unsigned int x = 0; x <= X_SEGMENTS; ++x)
{
indices.push_back(y * (X_SEGMENTS + 1) + x);
indices.push_back((y + 1) * (X_SEGMENTS + 1) + x);
@@ -406,7 +405,7 @@ void renderSphere()
}
else
{
for (int x = X_SEGMENTS; x >= 0; --x)
for (unsigned int x = X_SEGMENTS; x >= 0; --x)
{
indices.push_back((y + 1) * (X_SEGMENTS + 1) + x);
indices.push_back(y * (X_SEGMENTS + 1) + x);
@@ -417,7 +416,7 @@ void renderSphere()
indexCount = indices.size();
std::vector<float> data;
for (int i = 0; i < positions.size(); ++i)
for (unsigned int i = 0; i < positions.size(); ++i)
{
data.push_back(positions[i].x);
data.push_back(positions[i].y);

View File

@@ -347,7 +347,6 @@ void processInput(GLFWwindow *window)
if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS)
glfwSetWindowShouldClose(window, true);
float cameraSpeed = 2.5 * deltaTime;
if (glfwGetKey(window, GLFW_KEY_W) == GLFW_PRESS)
camera.ProcessKeyboard(FORWARD, deltaTime);
if (glfwGetKey(window, GLFW_KEY_S) == GLFW_PRESS)
@@ -434,11 +433,11 @@ void renderSphere()
}
bool oddRow = false;
for (int y = 0; y < Y_SEGMENTS; ++y)
for (unsigned int y = 0; y < Y_SEGMENTS; ++y)
{
if (!oddRow) // even rows: y == 0, y == 2; and so on
{
for (int x = 0; x <= X_SEGMENTS; ++x)
for (unsigned int x = 0; x <= X_SEGMENTS; ++x)
{
indices.push_back(y * (X_SEGMENTS + 1) + x);
indices.push_back((y + 1) * (X_SEGMENTS + 1) + x);
@@ -446,7 +445,7 @@ void renderSphere()
}
else
{
for (int x = X_SEGMENTS; x >= 0; --x)
for (unsigned int x = X_SEGMENTS; x >= 0; --x)
{
indices.push_back((y + 1) * (X_SEGMENTS + 1) + x);
indices.push_back(y * (X_SEGMENTS + 1) + x);
@@ -457,7 +456,7 @@ void renderSphere()
indexCount = indices.size();
std::vector<float> data;
for (int i = 0; i < positions.size(); ++i)
for (std::size_t i = 0; i < positions.size(); ++i)
{
data.push_back(positions[i].x);
data.push_back(positions[i].y);

View File

@@ -445,7 +445,6 @@ void processInput(GLFWwindow *window)
if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS)
glfwSetWindowShouldClose(window, true);
float cameraSpeed = 2.5 * deltaTime;
if (glfwGetKey(window, GLFW_KEY_W) == GLFW_PRESS)
camera.ProcessKeyboard(FORWARD, deltaTime);
if (glfwGetKey(window, GLFW_KEY_S) == GLFW_PRESS)
@@ -532,11 +531,11 @@ void renderSphere()
}
bool oddRow = false;
for (int y = 0; y < Y_SEGMENTS; ++y)
for (unsigned int y = 0; y < Y_SEGMENTS; ++y)
{
if (!oddRow) // even rows: y == 0, y == 2; and so on
{
for (int x = 0; x <= X_SEGMENTS; ++x)
for (unsigned int x = 0; x <= X_SEGMENTS; ++x)
{
indices.push_back(y * (X_SEGMENTS + 1) + x);
indices.push_back((y + 1) * (X_SEGMENTS + 1) + x);
@@ -544,7 +543,7 @@ void renderSphere()
}
else
{
for (int x = X_SEGMENTS; x >= 0; --x)
for (unsigned int x = X_SEGMENTS; x >= 0; --x)
{
indices.push_back((y + 1) * (X_SEGMENTS + 1) + x);
indices.push_back(y * (X_SEGMENTS + 1) + x);
@@ -555,7 +554,7 @@ void renderSphere()
indexCount = indices.size();
std::vector<float> data;
for (int i = 0; i < positions.size(); ++i)
for (std::size_t i = 0; i < positions.size(); ++i)
{
data.push_back(positions[i].x);
data.push_back(positions[i].y);

View File

@@ -156,9 +156,6 @@ int main()
glm::vec3(300.0f, 300.0f, 300.0f),
glm::vec3(300.0f, 300.0f, 300.0f)
};
int nrRows = 7;
int nrColumns = 7;
float spacing = 2.5;
// pbr: setup framebuffer
// ----------------------
@@ -548,7 +545,6 @@ void processInput(GLFWwindow *window)
if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS)
glfwSetWindowShouldClose(window, true);
float cameraSpeed = 2.5 * deltaTime;
if (glfwGetKey(window, GLFW_KEY_W) == GLFW_PRESS)
camera.ProcessKeyboard(FORWARD, deltaTime);
if (glfwGetKey(window, GLFW_KEY_S) == GLFW_PRESS)
@@ -635,11 +631,11 @@ void renderSphere()
}
bool oddRow = false;
for (int y = 0; y < Y_SEGMENTS; ++y)
for (unsigned int y = 0; y < Y_SEGMENTS; ++y)
{
if (!oddRow) // even rows: y == 0, y == 2; and so on
{
for (int x = 0; x <= X_SEGMENTS; ++x)
for (unsigned int x = 0; x <= X_SEGMENTS; ++x)
{
indices.push_back(y * (X_SEGMENTS + 1) + x);
indices.push_back((y + 1) * (X_SEGMENTS + 1) + x);
@@ -647,7 +643,7 @@ void renderSphere()
}
else
{
for (int x = X_SEGMENTS; x >= 0; --x)
for (unsigned int x = X_SEGMENTS; x >= 0; --x)
{
indices.push_back((y + 1) * (X_SEGMENTS + 1) + x);
indices.push_back(y * (X_SEGMENTS + 1) + x);
@@ -658,7 +654,7 @@ void renderSphere()
indexCount = indices.size();
std::vector<float> data;
for (int i = 0; i < positions.size(); ++i)
for (unsigned int i = 0; i < positions.size(); ++i)
{
data.push_back(positions[i].x);
data.push_back(positions[i].y);